/* ----------------------------------------------------------------------------- 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 { \ Testing.checkEquals(typename().formatted(), "String") } unittest int { \ Testing.checkEquals(typename().formatted(), "Int") } unittest char { \ Testing.checkEquals(typename().formatted(), "Char") } unittest charBuffer { \ Testing.checkEquals(typename().formatted(), "CharBuffer") } unittest float { \ Testing.checkEquals(typename().formatted(), "Float") } unittest bool { \ Testing.checkEquals(typename().formatted(), "Bool") } unittest anyType { \ Testing.checkEquals(typename().formatted(), "any") } unittest allType { \ Testing.checkEquals(typename().formatted(), "all") } unittest intersectDedup { \ Testing.checkEquals(typename<[AsBool & Char & Formatted & Int]>().formatted(), typename<[Char & Int]>().formatted()) } unittest unionDedup { \ Testing.checkEquals(typename<[AsBool | Char | Formatted | Int]>().formatted(), typename<[AsBool | Formatted]>().formatted()) } unittest param { \ Testing.checkEquals(Wrapped:getTypename>().formatted(), "Type>") } unittest intersectParam { String text <- Wrapped:getTypenameIntersect().formatted() if (text != "[Formatted&Int]") { fail(text) } } unittest unionParam { String text <- Wrapped:getTypenameUnion().formatted() if (text != "[Formatted|Int]") { fail(text) } } unittest intersectDedupParam { \ Testing.checkEquals(Wrapped:getTypenameIntersect().formatted(), "Int") } unittest unionDedupParam { \ Testing.checkEquals(Wrapped:getTypenameUnion().formatted(), "Int") } @value interface Value<#x> { } @value interface Type<#x, #y> { } concrete Wrapped { @category getTypename<#x, #y> () -> (Formatted) @category getTypenameIntersect<#x, #y> () -> (Formatted) @category getTypenameUnion<#x, #y> () -> (Formatted) } define Wrapped { getTypename () { return typename>() } getTypenameIntersect () { return typename<[#x & #y]>() } getTypenameUnion () { return typename<[#x | #y]>() } }