/* ----------------------------------------------------------------------------- Copyright 2020 Kevin P. Barry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ----------------------------------------------------------------------------- */ // Author: Kevin P. Barry [ta0kira@gmail.com] testcase "internal category types are checked" { error require "Formatted" require "type interface" } concrete Value { @type create () -> (Value) } define Value { defines Formatted } testcase "internal refine is private" { success } unittest test { String value <- Value.create().get().formatted() if (value != "Value") { fail(value) } } concrete Value { @type create () -> (Value) @value get () -> (Formatted) } define Value { refines Formatted create () { return Value{ } } get () { return self } formatted () { return "Value" } } testcase "internal refine is not public" { error require "refine" require "Formatted" require "Value" } unittest test { Formatted value <- Value.create() } concrete Value { @type create () -> (Value) } define Value { refines Formatted create () { return Value{ } } formatted () { return "Value" } } testcase "internal define links properly for dispatching" { success } unittest test {} concrete Value {} define Value { refines Formatted defines Equals formatted () { return "Value" } equals (_,_) { return true } } testcase "internal define is visible privately" { success } unittest test { Value value1 <- Value.create(1) Value value2 <- Value.create(2) if (Value.compare(value1,value2)) { fail("Failed") } } concrete Compare<#x> { #x defines Equals<#x> @type compare (#x,#x) -> (Bool) } define Compare { compare (x,y) { return #x.equals(x,y) } } concrete Value { @type create (Int) -> (Value) @type compare (Value,Value) -> (Bool) } define Value { defines Equals @value Int value equals (x,y) { return x.get() == y.get() } create (x) { return Value{ x } } compare (x,y) { return Compare.compare(x,y) } @value get () -> (Int) get () { return value } } testcase "internal define is not public" { error require "define" require "Equals" require "Value" } unittest test { Value value1 <- Value.create(1) Value value2 <- Value.create(2) \ Compare.compare(value1,value2) } concrete Compare<#x> { #x defines Equals<#x> @type compare (#x,#x) -> (Bool) } define Compare { compare (x,y) { return #x.equals(x,y) } } concrete Value { @type create (Int) -> (Value) } define Value { defines Equals @value Int value equals (x,y) { return x.get() == y.get() } create (x) { return Value{ x } } @value get () -> (Int) get () { return value } }