diff --git a/test/definition/using/binary_type_alias.casm b/test/definition/using/binary_type_alias.casm new file mode 100644 index 00000000..0050570a --- /dev/null +++ b/test/definition/using/binary_type_alias.casm @@ -0,0 +1,31 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +using uint16_t = Binary'16 + +rule foo = + let x : uint16_t = 0b1010'1111'1111'1110 in + skip diff --git a/test/definition/using/boolean_type_alias.casm b/test/definition/using/boolean_type_alias.casm new file mode 100644 index 00000000..33a2fcf6 --- /dev/null +++ b/test/definition/using/boolean_type_alias.casm @@ -0,0 +1,31 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +using MyType = Boolean + +rule foo = + let x : MyType = true in + skip diff --git a/test/definition/using/enumeration_type_alias.casm b/test/definition/using/enumeration_type_alias.casm new file mode 100644 index 00000000..2c0a62b6 --- /dev/null +++ b/test/definition/using/enumeration_type_alias.casm @@ -0,0 +1,37 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +enumeration Color = { + Red, + Green, + Blue +} + +using MyType = Color + +rule foo = + let x : MyType = ::Red in + skip diff --git a/test/definition/using/error/enumerator_alias.casm b/test/definition/using/error/enumerator_alias.casm new file mode 100644 index 00000000..36e8917a --- /dev/null +++ b/test/definition/using/error/enumerator_alias.casm @@ -0,0 +1,39 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +// type check pass should say that the enumerator 'Color::Red' cannot be used +// as a type + +CASM init foo + +enumeration Color = { + Red, + Green, + Blue +} + +using MyType = Color::Red //@ ERROR( 0100 ) + +rule foo = + skip diff --git a/test/definition/using/error/redefinition.casm b/test/definition/using/error/redefinition.casm new file mode 100644 index 00000000..36d76a93 --- /dev/null +++ b/test/definition/using/error/redefinition.casm @@ -0,0 +1,33 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +// symbol registration should say that symbol 'MyType' is already defined + +CASM init foo + +using MyType = Boolean //@ ERROR( 0502 ) +using MyType = Integer //@ ERROR( 0502 ) + +rule foo = + skip diff --git a/test/definition/using/error/using_unknown_type.casm b/test/definition/using/error/using_unknown_type.casm new file mode 100644 index 00000000..f65596c6 --- /dev/null +++ b/test/definition/using/error/using_unknown_type.casm @@ -0,0 +1,32 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +// type check pass should say that the type 'UnknownType' is unknown + +CASM init foo + +using MyType = UnknownType //@ ERROR( 0100 ) + +rule foo = + skip diff --git a/test/definition/using/function_reference_type_alias.casm b/test/definition/using/function_reference_type_alias.casm new file mode 100644 index 00000000..ece6e014 --- /dev/null +++ b/test/definition/using/function_reference_type_alias.casm @@ -0,0 +1,34 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +using MyFuncRef = FuncRef< Integer * Integer -> Integer > + +derived d( a : Integer, b : Integer ) -> Integer = + a + b + +rule foo = + let x : MyFuncRef = @d in + skip diff --git a/test/definition/using/type_alias_in_type_alias.casm b/test/definition/using/type_alias_in_type_alias.casm new file mode 100644 index 00000000..8a509ed3 --- /dev/null +++ b/test/definition/using/type_alias_in_type_alias.casm @@ -0,0 +1,33 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +using MyType1 = Boolean +using MyType2 = MyType1 + +function test : MyType1 -> MyType2 + +rule foo = + skip diff --git a/test/definition/using/use_type_alias_as_universe.casm b/test/definition/using/use_type_alias_as_universe.casm new file mode 100644 index 00000000..1eaf5291 --- /dev/null +++ b/test/definition/using/use_type_alias_as_universe.casm @@ -0,0 +1,44 @@ +// +// Copyright (c) 2014-2017 CASM Organization +// All rights reserved. +// +// Developed by: Philipp Paulweber +// Emmanuel Pescosta +// https://github.com/casm-lang/libcasm-tc +// +// This file is part of libcasm-tc. +// +// libcasm-tc is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libcasm-tc is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libcasm-tc. If not, see . +// + +CASM init foo + +enumeration State = { + On, + Off +} + +using MyState = State + +function visitedStates : MyState -> Boolean + +rule foo = +{| + forall s in MyState do + visitedStates( s ) := true + + assert( visitedStates( ::On ) and visitedStates( ::Off ) ) + + program( self ) := undef +|}