TYPED: f+ ( a: float b: float -- c: float )
+ ;
-[ 3.5 ]
+{ 3.5 }
[ 2 1+1/2 f+ ] unit-test
TYPED: fix+ ( a: fixnum b: fixnum -- c: fixnum )
TYPED:: f+locals ( a: float b: float -- c: float )
a b + ;
-[ 3.5 ] [ 2 1+1/2 f+locals ] unit-test
+{ 3.5 } [ 2 1+1/2 f+locals ] unit-test
TUPLE: unboxable
{ x fixnum read-only }
TYPED: unboxy ( in: unboxable -- out: unboxable2 )
dup [ x>> ] [ y>> ] bi - unboxable2 boa ;
-[ ( in: fixnum in: fixnum -- out: fixnum out: fixnum out: fixnum ) ]
+{ ( in: fixnum in: fixnum -- out: fixnum out: fixnum out: fixnum ) }
[ \ unboxy "typed-word" word-prop stack-effect ] unit-test
-[ T{ unboxable2 { u T{ unboxable { x 12 } { y 3 } } } { xy 9 } } ]
+{ T{ unboxable2 { u T{ unboxable { x 12 } { y 3 } } } { xy 9 } } }
[ T{ unboxable { x 12 } { y 3 } } unboxy ] unit-test
-[ 9 ]
+{ 9 }
[
"""
USING: kernel math ;
TYPED: no-inputs ( -- out: integer )
1 ;
-[ 1 ] [ no-inputs ] unit-test
+{ 1 } [ no-inputs ] unit-test
TUPLE: unboxable3
{ x read-only } ; final
TYPED: no-inputs-unboxable-output ( -- out: unboxable3 )
T{ unboxable3 } ;
-[ T{ unboxable3 } ] [ no-inputs-unboxable-output ] unit-test
+{ T{ unboxable3 } } [ no-inputs-unboxable-output ] unit-test
-[ f ] [ no-inputs-unboxable-output no-inputs-unboxable-output eq? ] unit-test
+{ f } [ no-inputs-unboxable-output no-inputs-unboxable-output eq? ] unit-test
SYMBOL: buh
TYPED: no-outputs ( x: integer -- )
buh set ;
-[ 2 ] [ 2 no-outputs buh get ] unit-test
+{ 2 } [ 2 no-outputs buh get ] unit-test
TYPED: no-outputs-unboxable-input ( x: unboxable3 -- )
buh set ;
-[ T{ unboxable3 } ] [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test
+{ T{ unboxable3 } } [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test
-[ f ] [
+{ f } [
T{ unboxable3 } no-outputs-unboxable-input buh get
T{ unboxable3 } no-outputs-unboxable-input buh get
eq?
TYPED: unbox-fail ( a: superclass -- ? ) subclass? ;
-[ t ] [ subclass new unbox-fail ] unit-test
+{ t } [ subclass new unbox-fail ] unit-test
! If a final class becomes non-final, typed words need to be recompiled
TYPED: recompile-fail ( a: subclass -- ? ) buh get eq? ;
-[ f ] [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test
+{ f } [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test
-[ ] [ "IN: typed.tests TUPLE: subclass < superclass { y read-only } ;" eval( -- ) ] unit-test
+{ } [ "IN: typed.tests TUPLE: subclass < superclass { y read-only } ;" eval( -- ) ] unit-test
-[ t ] [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test
+{ t } [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test
! Make sure that foldable and flushable work on typed words
TYPED: add ( a: integer b: integer -- c: integer ) + ; foldable
-[ [ 3 ] ] [ [ 1 2 add ] cleaned-up-tree nodes>quot ] unit-test
+{ [ 3 ] } [ [ 1 2 add ] cleaned-up-tree nodes>quot ] unit-test
TYPED: flush-test ( s: symbol -- ? ) on t ; flushable
SYMBOL: a-symbol
-[ f ] [
+{ f } [
f a-symbol [
a-symbol flush-print-1
a-symbol get
] with-variable
] unit-test
-[ t ] [
+{ t } [
f a-symbol [
a-symbol flush-print-2
a-symbol get
TYPED: forget-fail ( a: forget-class -- ) drop ;
-[ ] [ [ \ forget-class forget ] with-compilation-unit ] unit-test
+{ } [ [ \ forget-class forget ] with-compilation-unit ] unit-test
-[ ] [ [ \ forget-fail forget ] with-compilation-unit ] unit-test
+{ } [ [ \ forget-fail forget ] with-compilation-unit ] unit-test
TYPED: typed-maybe ( x: maybe{ integer } -- ? ) >boolean ;
-[ f ] [ f typed-maybe ] unit-test
-[ t ] [ 30 typed-maybe ] unit-test
+{ f } [ f typed-maybe ] unit-test
+{ t } [ 30 typed-maybe ] unit-test
[ 30.0 typed-maybe ] [ input-mismatch-error? ] must-fail-with
TYPED: typed-union ( x: union{ integer string } -- ? ) >boolean ;
-[ t ] [ 3 typed-union ] unit-test
-[ t ] [ "asdf" typed-union ] unit-test
+{ t } [ 3 typed-union ] unit-test
+{ t } [ "asdf" typed-union ] unit-test
[ 3.3 typed-union ] [ input-mismatch-error? ] must-fail-with
TYPED: typed-intersection ( x: intersection{ integer bignum } -- ? ) >boolean ;
-[ t ] [ 5555555555555555555555555555555555555555555555555555 typed-intersection ] unit-test
+{ t } [ 5555555555555555555555555555555555555555555555555555 typed-intersection ] unit-test
[ 0 typed-intersection ] [ input-mismatch-error? ] must-fail-with
[