TestCase.st
changeset 97 1f7ff8664715
parent 95 06622db7c5a8
child 101 3eac160a3c2f
--- a/TestCase.st	Thu Jan 23 12:12:27 2003 +0100
+++ b/TestCase.st	Fri May 09 19:42:33 2003 +0200
@@ -201,7 +201,14 @@
 	^true
 ! !
 
-!TestCase methodsFor:'accessing'!
+!TestCase methodsFor:'accessing & queries'!
+
+unfinished
+
+	"indicates an unfinished test"
+! !
+
+!TestCase methodsFor:'assertions'!
 
 assert: aBoolean
     "fail, if the argument is not true"
@@ -213,6 +220,31 @@
     self assert: aBoolean message:'Assertion failed'
 !
 
+assert:aBlock completesInSeconds:aNumber
+    "fail, if aBlock does not finish its work in aNumber seconds"
+
+    |done process semaphore|
+
+    done := false.
+    semaphore := Semaphore new.
+    [
+        process := Processor activeProcess.
+        aBlock value.
+        done := true.
+        semaphore signal
+    ] fork.
+    semaphore waitWithTimeout: aNumber.
+    process terminate.
+    self assert: done       
+
+    "
+     self new assert:[Delay waitForSeconds:2] completesInSeconds:1
+    "
+    "
+     self new assert:[Delay waitForSeconds:1] completesInSeconds:2
+    "
+!
+
 assert: aBoolean message:messageIfFailing
     "fail, if the argument is not true"
 
@@ -288,13 +320,6 @@
     "Modified: / 21.6.2000 / 10:01:34 / Sames"
 ! !
 
-!TestCase methodsFor:'accessing & queries'!
-
-unfinished
-
-	"indicates an unfinished test"
-! !
-
 !TestCase methodsFor:'dependencies'!
 
 addDependentToHierachy: anObject 
@@ -422,7 +447,7 @@
 !TestCase class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.33 2002-12-10 10:06:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.34 2003-05-09 17:42:33 cg Exp $'
 ! !
 
 TestCase initialize!