From b3ded6e42c75f8c0db83349d2955e54ef1fd7d78 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Tue, 31 Oct 2017 15:14:12 +0000 Subject: [PATCH] changed test-004 further --- moo/kernel/test-004.moo | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/moo/kernel/test-004.moo b/moo/kernel/test-004.moo index f23f083..44a2d0e 100644 --- a/moo/kernel/test-004.moo +++ b/moo/kernel/test-004.moo @@ -10,18 +10,42 @@ class MyObject(Object) { - var(#class) t := 20. + var(#class) t1 := 20. method(#class) test_terminate { | a s | s := Semaphore new. - a := [ self.t := self.t * 9. + a := [ self.t1 := self.t1 * 9. s signal. Processor activeProcess terminate. - self.t := self.t + 20 ] fork. + self.t1 := self.t1 + 20 ] fork. s wait. - ^self.t + ^self.t1 + } + + method(#class) test_sg + { + | sg s1 s2 s3 | + + s1 := Semaphore new. + s2 := Semaphore new. + s3 := Semaphore new. + + sg := SemaphoreGroup new. + sg addSemaphore: s1. + sg addSemaphore: s2. + sg addSemaphore: s3. + + Processor signal: s1 onInput: 0. + Processor signal: s2 onInput: 0. ## this should raise an exception. + Processor signal: s3 onInput: 0. + + [ sg wait. ] fork. + [ sg wait. ] fork. + [ sg wait. ] fork. + + sg wait. } method(#class) main @@ -30,7 +54,8 @@ class MyObject(Object) tc := %( ## 0 - 4 - [self test_terminate == 180] + [self test_terminate == 180], + [self test_sg == nil] ). limit := tc size.