moo/moo/kernel/test-003.moo

67 lines
1.5 KiB
Smalltalk

##
## TEST CASES for basic methods
##
#include 'Moo.moo'.
#################################################################
## MAIN
#################################################################
class MyObject(Object)
{
var(#classinst) t1, t2.
method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 100) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
method(#class) main
{
| tc limit |
tc := %(
## 0 - 4
[(Object isKindOf: Class) == true],
[(Object isKindOf: Apex) == true],
[(Class isKindOf: Class) == true],
[(Class isKindOf: Apex) == true],
[(Class isKindOf: Object) == false],
## 5-9
[(Apex isKindOf: Class) == true],
[(Apex isKindOf: Apex) == true],
[(SmallInteger isKindOf: Integer) == false],
[(SmallInteger isKindOf: SmallInteger) == false],
[(Object isKindOf: SmallInteger) == false],
## 10-14
[(10 isKindOf: Integer) == true],
[(10 isKindOf: 20) == false],
[([] isKindOf: BlockContext) == true],
[([] isKindOf: MethodContext) == false],
[([] isKindOf: Context) == true],
## 15-20
[('string' isKindOf: String) == true],
[(#symbol isKindOf: String) == true],
[('string' isKindOf: Symbol) == false],
[(#symbol isKindOf: Symbol) == true]
).
limit := tc size.
0 priorTo: limit by: 1 do: [ :idx |
| tb |
tb := tc at: idx.
System log(System.Log.INFO, idx asString, (if (tb value) { ' PASS' } else { ' FAIL' }), S'\n').
]
}
}