factor/basis/cocoa/cocoa-tests.factor

55 lines
1.2 KiB
Factor
Raw Normal View History

USING: alien.c-types cocoa cocoa.classes cocoa.subclassing
cocoa.types compiler.test core-graphics.types kernel math memory
namespaces tools.test ;
IN: cocoa.tests
2007-09-20 18:09:08 -04:00
<CLASS: Foo < NSObject
METHOD: void foo: NSRect rect [
gc rect "x" set
] ;
;CLASS>
2007-09-20 18:09:08 -04:00
2009-03-23 01:34:02 -04:00
: test-foo ( -- )
Foo send\ alloc send\ init
dup 1.0 2.0 101.0 102.0 <CGRect> send\ foo:
send\ release ;
2007-09-20 18:09:08 -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 ] ;
;CLASS>
2007-09-20 18:09:08 -04:00
{ } [
2011-08-29 01:20:39 -04:00
Bar [
send\ alloc send\ init
dup send\ bar "x" set
send\ release
2011-08-29 01:20:39 -04:00
] 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 ] ;
;CLASS>
2008-12-04 22:22:48 -05:00
{ 144 } [
2008-12-04 22:22:48 -05:00
Bar [
send\ alloc send\ init
dup 12 send\ babb:
swap send\ release
2008-12-04 22:22:48 -05:00
] compile-call
] unit-test