/* ----------------------------------------------------------------------------- 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 "builtin typenames" { success } unittest string { Formatted name <- typename() if (name.formatted() != "String") { fail(name) } } unittest int { Formatted name <- typename() if (name.formatted() != "Int") { fail(name) } } unittest char { Formatted name <- typename() if (name.formatted() != "Char") { fail(name) } } unittest float { Formatted name <- typename() if (name.formatted() != "Float") { fail(name) } } unittest bool { Formatted name <- typename() if (name.formatted() != "Bool") { fail(name) } } unittest formatted { Formatted name <- typename() if (name.formatted() != "Formatted") { fail(name) } } unittest anyType { Formatted name <- typename() if (name.formatted() != "any") { fail(name) } } unittest allType { Formatted name <- typename() if (name.formatted() != "all") { fail(name) } } unittest intersect { Formatted name <- typename<[String&Int]>() if (name.formatted() != "[Int&String]") { fail(name) } } unittest union { Formatted name <- typename<[String|Int]>() if (name.formatted() != "[Int|String]") { fail(name) } } @value interface Value<#x> {} @value interface Type<#x,#y> {} define Wrapped { getTypename () { return typename>() } } concrete Wrapped { @category getTypename<#x,#y> () -> (Formatted) } unittest param { Formatted name <- Wrapped:getTypename>() if (name.formatted() != "Type>") { fail(name) } } testcase "bad instance in typename param" { error require "Test" require "define" require "Equals" } unittest test { \ typename>() } @value interface Value<#x> { #x defines Equals<#x> } concrete Test {} define Test {}