factor/basis/cocoa/cocoa-tests.factor

59 lines
1.2 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
USING: cocoa cocoa.messages cocoa.subclassing cocoa.types
compiler.test kernel namespaces cocoa.classes cocoa.runtime
2009-10-21 19:19:35 -04:00
tools.test memory compiler.units math core-graphics.types ;
FROM: alien.c-types => int void ;
IN: cocoa.tests
2007-09-20 18:09:08 -04:00
CLASS: Foo < NSObject
[
METHOD: void foo: NSRect rect [
gc rect "x" set
]
]
2007-09-20 18:09:08 -04:00
2009-03-23 01:34:02 -04:00
: test-foo ( -- )
2007-09-20 18:09:08 -04:00
Foo -> alloc -> init
dup 1.0 2.0 101.0 102.0 <CGRect> -> foo:
2007-09-20 18:09:08 -04:00
-> release ;
2011-08-29 01:20:39 -04:00
[ ] [ test-foo ] unit-test
2007-09-20 18:09:08 -04:00
[ 1.0 ] [ "x" get CGRect-x ] unit-test
[ 2.0 ] [ "x" get CGRect-y ] unit-test
[ 101.0 ] [ "x" get CGRect-w ] unit-test
[ 102.0 ] [ "x" get CGRect-h ] unit-test
2007-09-20 18:09:08 -04:00
CLASS: Bar < NSObject
[
METHOD: NSRect bar [ test-foo "x" get ]
]
2007-09-20 18:09:08 -04:00
2011-08-29 01:20:39 -04:00
[ ] [
Bar [
-> alloc -> init
dup -> bar "x" set
-> release
] compile-call
] unit-test
2007-09-20 18:09:08 -04:00
[ 1.0 ] [ "x" get CGRect-x ] unit-test
[ 2.0 ] [ "x" get CGRect-y ] unit-test
[ 101.0 ] [ "x" get CGRect-w ] unit-test
[ 102.0 ] [ "x" get CGRect-h ] unit-test
2008-12-04 22:22:48 -05:00
! Make sure that we can add methods
CLASS: Bar < NSObject
[
METHOD: NSRect bar [ test-foo "x" get ]
METHOD: int babb: int x [ x sq ]
]
2008-12-04 22:22:48 -05:00
[ 144 ] [
Bar [
-> alloc -> init
dup 12 -> babb:
2008-12-04 22:22:48 -05:00
swap -> release
] compile-call
] unit-test