changed test-004.moo
This commit is contained in:
parent
8baf88b070
commit
c86018a644
@ -1,3 +1,6 @@
|
|||||||
|
##
|
||||||
|
## TEST CASES for basic methods
|
||||||
|
##
|
||||||
|
|
||||||
#include 'Moo.moo'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
@ -5,54 +8,37 @@
|
|||||||
## MAIN
|
## MAIN
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
## TODO: use #define to define a class or use #class to define a class.
|
class MyObject(Object)
|
||||||
## use #extend to extend a class
|
|
||||||
## using #class for both feels confusing.
|
|
||||||
|
|
||||||
extend Apex
|
|
||||||
{
|
{
|
||||||
|
var(#class) t := 20.
|
||||||
|
|
||||||
}
|
method(#class) test_terminate
|
||||||
|
|
||||||
extend SmallInteger
|
|
||||||
{
|
|
||||||
method getTrue: anInteger
|
|
||||||
{
|
{
|
||||||
^anInteger + 9999.
|
| a s |
|
||||||
}
|
s := Semaphore new.
|
||||||
|
a := [ self.t := self.t * 9.
|
||||||
method inc
|
s signal.
|
||||||
{
|
Processor activeProcess terminate.
|
||||||
^self + 1.
|
self.t := self.t + 20 ] fork.
|
||||||
}
|
s wait.
|
||||||
}
|
^self.t
|
||||||
|
|
||||||
class TestObject(Object)
|
|
||||||
{
|
|
||||||
var(#class) Q, R.
|
|
||||||
var(#classinst) a1, a2.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MyObject(TestObject)
|
|
||||||
{
|
|
||||||
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
|
method(#class) main
|
||||||
{
|
{
|
||||||
'START OF MAIN' dump.
|
| tc limit |
|
||||||
Processor activeProcess terminate.
|
|
||||||
'EDN OF MAIN' dump.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
tc := %(
|
||||||
|
## 0 - 4
|
||||||
|
[self test_terminate == 180]
|
||||||
|
).
|
||||||
|
|
||||||
|
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').
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user