2007-09-20 18:09:08 -04:00
|
|
|
USING: cocoa cocoa.messages cocoa.subclassing cocoa.types
|
2010-01-22 06:39:56 -05:00
|
|
|
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 ;
|
2009-08-13 20:21:44 -04:00
|
|
|
IN: cocoa.tests
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
CLASS: {
|
|
|
|
{ +superclass+ "NSObject" }
|
|
|
|
{ +name+ "Foo" }
|
2010-07-06 17:59:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2009-01-21 20:34:42 -05:00
|
|
|
dup 1.0 2.0 101.0 102.0 <CGRect> -> foo:
|
2007-09-20 18:09:08 -04:00
|
|
|
-> release ;
|
|
|
|
|
|
|
|
test-foo
|
|
|
|
|
2009-01-21 20:34:42 -05: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: {
|
|
|
|
{ +superclass+ "NSObject" }
|
|
|
|
{ +name+ "Bar" }
|
2010-07-06 17:59:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
METHOD: NSRect bar [ test-foo "x" get ] ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
Bar [
|
|
|
|
-> alloc -> init
|
|
|
|
dup -> bar "x" set
|
|
|
|
-> release
|
2008-01-09 01:36:11 -05:00
|
|
|
] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-01-21 20:34:42 -05: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: {
|
|
|
|
{ +superclass+ "NSObject" }
|
|
|
|
{ +name+ "Bar" }
|
2010-07-06 17:59:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2010-07-06 17:59:35 -04:00
|
|
|
dup 12 -> babb:
|
2008-12-04 22:22:48 -05:00
|
|
|
swap -> release
|
|
|
|
] compile-call
|
|
|
|
] unit-test
|