/* ----------------------------------------------------------------------------- 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 Test$run() } concrete Value { @type create () -> (Value) @value get () -> (Formatted) } define Value { refines Formatted create () { return Value{ } } get () { return self } formatted () { return "Value" } } define Test { run () { String value <- Value$create().get().formatted() if (value != "Value") { fail(value) } } } concrete Test { @type run () -> () } testcase "internal refine is not public" { error require "refine" require "Formatted" require "Value" } concrete Value { @type create () -> (Value) } define Value { refines Formatted create () { return Value{ } } formatted () { return "Value" } } define Test { run () { Formatted value <- Value$create() } } concrete Test { @type run () -> () } testcase "internal define is private" { success Test$run() } 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 } } define Test { run () { Value value1 <- Value$create(1) Value value2 <- Value$create(2) if (Value$compare(value1,value2)) { fail("Failed") } } } concrete Test { @type run () -> () } testcase "internal define is not public" { error require "define" require "Equals" require "Value" } 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 } } define Test { run () { Value value1 <- Value$create(1) Value value2 <- Value$create(2) if (Compare$compare(value1,value2)) { fail("Failed") } } } concrete Test { @type run () -> () }