moo/moo/kernel/test-004.moo

45 lines
773 B
Smalltalk
Raw Normal View History

2017-10-31 15:08:58 +00:00
##
## TEST CASES for basic methods
##
2016-03-28 13:27:03 +00:00
2017-01-09 12:52:37 +00:00
#include 'Moo.moo'.
2016-03-28 13:27:03 +00:00
#################################################################
## MAIN
#################################################################
2017-10-31 15:08:58 +00:00
class MyObject(Object)
2016-03-28 13:27:03 +00:00
{
2017-10-31 15:08:58 +00:00
var(#class) t := 20.
2016-03-28 13:27:03 +00:00
2017-10-31 15:08:58 +00:00
method(#class) test_terminate
2016-03-28 13:27:03 +00:00
{
2017-10-31 15:08:58 +00:00
| a s |
s := Semaphore new.
a := [ self.t := self.t * 9.
s signal.
Processor activeProcess terminate.
self.t := self.t + 20 ] fork.
s wait.
^self.t
2016-03-28 13:27:03 +00:00
}
2017-10-31 15:08:58 +00:00
method(#class) main
2016-03-28 13:27:03 +00:00
{
2017-10-31 15:08:58 +00:00
| tc limit |
2016-03-28 13:27:03 +00:00
2017-10-31 15:08:58 +00:00
tc := %(
## 0 - 4
[self test_terminate == 180]
).
2016-03-28 13:27:03 +00:00
2017-10-31 15:08:58 +00:00
limit := tc size.
2016-03-28 13:27:03 +00:00
2017-10-31 15:08:58 +00:00
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').
]
2016-03-28 13:27:03 +00:00
}
}