Просмотр исходного кода

- More Sunit refactorings and reformattings
- renamed TestCase >> graceTime: to #timeout:

Nicolas Petton 11 лет назад
Родитель
Сommit
1bacdd8b9c
6 измененных файлов с 170 добавлено и 165 удалено
  1. 29 29
      js/SUnit-Tests.deploy.js
  2. 55 55
      js/SUnit-Tests.js
  3. 22 22
      js/SUnit.deploy.js
  4. 28 28
      js/SUnit.js
  5. 25 25
      st/SUnit-Tests.st
  6. 11 6
      st/SUnit.st

+ 29 - 29
js/SUnit-Tests.deploy.js

@@ -101,7 +101,7 @@ selector: "fakeError",
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 self["@flag"]="ok";
 self["@flag"];
@@ -118,7 +118,7 @@ selector: "fakeErrorFailingInTearDown",
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_error_",["Intentional"]);
 })]),"_valueWithTimeout_",[(5)]);
@@ -133,7 +133,7 @@ selector: "fakeFailure",
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 self["@flag"]="ok";
 self["@flag"];
@@ -144,31 +144,28 @@ return self}
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeMultipleGraceTimeFailing",
+"_fakeTimeout",
 smalltalk.method({
-selector: "fakeMultipleGraceTimeFailing",
+selector: "fakeTimeout",
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(100)]);
+smalltalk.send(self,"_timeout_",[(4)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-smalltalk.send(self,"_graceTime_",[(5)]);
-return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
-})]),"_valueWithTimeout_",[(10)]);
 })]),"_valueWithTimeout_",[(5)]);
 return self}
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeMultipleGraceTimePassing",
+"_fakeTimeoutFailing",
 smalltalk.method({
-selector: "fakeMultipleGraceTimePassing",
+selector: "fakeTimeoutFailing",
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(100)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-smalltalk.send(self,"_graceTime_",[(20)]);
+smalltalk.send(self,"_timeout_",[(5)]);
 return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 })]),"_valueWithTimeout_",[(10)]);
@@ -178,14 +175,17 @@ return self}
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeTimeout",
+"_fakeTimeoutPassing",
 smalltalk.method({
-selector: "fakeTimeout",
+selector: "fakeTimeoutPassing",
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(4)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_timeout_",[(20)]);
+return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
+})]),"_valueWithTimeout_",[(10)]);
 })]),"_valueWithTimeout_",[(5)]);
 return self}
 }),
@@ -243,7 +243,7 @@ suite=smalltalk.send(["fakeError", "fakeErrorFailingInTearDown", "fakeFailure",
 return smalltalk.send(smalltalk.send(self,"_class",[]),"_selector_",[each]);
 })]);
 runner=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(self,"_graceTime_",[(200)]);
+smalltalk.send(self,"_timeout_",[(200)]);
 result=smalltalk.send(runner,"_result",[]);
 assertBlock=smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_equals_",[["fakeError"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_errors",[])])]);
@@ -267,16 +267,16 @@ return self}
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_testAsyncNeedsGraceTime",
+"_testAsyncNeedsTimeout",
 smalltalk.method({
-selector: "testAsyncNeedsGraceTime",
+selector: "testAsyncNeedsTimeout",
 fn: function (){
 var self=this;
 smalltalk.send(self,"_should_raise_",[(function(){
 return smalltalk.send(self,"_async_",[(function(){
 })]);
 }),(smalltalk.Error || Error)]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_shouldnt_raise_",[(function(){
 return smalltalk.send(self,"_async_",[(function(){
 })]);
@@ -287,15 +287,15 @@ return self}
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_testFinishedNeedsGraceTime",
+"_testFinishedNeedsTimeout",
 smalltalk.method({
-selector: "testFinishedNeedsGraceTime",
+selector: "testFinishedNeedsTimeout",
 fn: function (){
 var self=this;
 smalltalk.send(self,"_should_raise_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 }),(smalltalk.Error || Error)]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_shouldnt_raise_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 }),(smalltalk.Error || Error)]);
@@ -310,7 +310,7 @@ selector: "testIsAsyncReturnsCorrectValues",
 fn: function (){
 var self=this;
 smalltalk.send(self,"_deny_",[smalltalk.send(self,"_isAsync",[])]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_assert_",[smalltalk.send(self,"_isAsync",[])]);
 smalltalk.send(self,"_finished",[]);
 smalltalk.send(self,"_deny_",[smalltalk.send(self,"_isAsync",[])]);
@@ -325,7 +325,7 @@ selector: "testPass",
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_",[true]);
 smalltalk.send(self,"_finished",[]);
@@ -347,15 +347,15 @@ var suite;
 var runner;
 var result;
 var assertBlock;
-suite=smalltalk.send(["fakeTimeout", "fakeMultipleGraceTimeFailing", "fakeMultipleGraceTimePassing", "testPass"],"_collect_",[(function(each){
+suite=smalltalk.send(["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"],"_collect_",[(function(each){
 return smalltalk.send(smalltalk.send(self,"_class",[]),"_selector_",[each]);
 })]);
 runner=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(self,"_graceTime_",[(200)]);
+smalltalk.send(self,"_timeout_",[(200)]);
 result=smalltalk.send(runner,"_result",[]);
 assertBlock=smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[])]);
-smalltalk.send(self,"_assert_equals_",[["fakeMultipleGraceTimeFailing", "fakeTimeout"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_failures",[])])]);
+smalltalk.send(self,"_assert_equals_",[["fakeMultipleTimeoutFailing", "fakeTimeout"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_failures",[])])]);
 return smalltalk.send(self,"_finished",[]);
 })]);
 $1=smalltalk.send(runner,"_announcer",[]);
@@ -382,7 +382,7 @@ fn: function (){
 var self=this;
 var x;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 x=(0);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_finished",[]);

+ 55 - 55
js/SUnit-Tests.js

@@ -138,7 +138,7 @@ category: 'helpers',
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 self["@flag"]="ok";
 self["@flag"];
@@ -146,8 +146,8 @@ return smalltalk.send(self,"_error_",["Intentional"]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self graceTime: 10.\x0a    flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "error:"],
+source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a    flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
@@ -160,14 +160,14 @@ category: 'helpers',
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_error_",["Intentional"]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self graceTime: 10.\x0a    flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "error:"],
+source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a    flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
@@ -180,7 +180,7 @@ category: 'helpers',
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 self["@flag"]="ok";
 self["@flag"];
@@ -188,71 +188,71 @@ return smalltalk.send(self,"_assert_",[false]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self graceTime: 10.\x0a    flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "assert:"],
+source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a    flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeMultipleGraceTimeFailing",
+"_fakeTimeout",
 smalltalk.method({
-selector: "fakeMultipleGraceTimeFailing",
+selector: "fakeTimeout",
 category: 'helpers',
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(100)]);
+smalltalk.send(self,"_timeout_",[(4)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-smalltalk.send(self,"_graceTime_",[(5)]);
-return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
-})]),"_valueWithTimeout_",[(10)]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeMultipleGraceTimeFailing\x0a\x09self graceTime: 100.\x0a    (self async: [\x0a\x09\x09self graceTime: 5.\x0a        (self async: [ self finished ]) valueWithTimeout: 10\x0a\x09]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "finished"],
+source: "fakeTimeout\x0a\x09self timeout: 4.\x0a    (self async: [ self finished ]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeMultipleGraceTimePassing",
+"_fakeTimeoutFailing",
 smalltalk.method({
-selector: "fakeMultipleGraceTimePassing",
+selector: "fakeTimeoutFailing",
 category: 'helpers',
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(100)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-smalltalk.send(self,"_graceTime_",[(20)]);
+smalltalk.send(self,"_timeout_",[(5)]);
 return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 })]),"_valueWithTimeout_",[(10)]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeMultipleGraceTimePassing\x0a\x09self graceTime: 10.\x0a    (self async: [\x0a\x09\x09self graceTime: 20.\x0a        (self async: [ self finished ]) valueWithTimeout: 10\x0a\x09]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "finished"],
+source: "fakeTimeoutFailing\x0a\x09self timeout: 100.\x0a    (self async: [\x0a\x09\x09self timeout: 5.\x0a        (self async: [ self finished ]) valueWithTimeout: 10\x0a\x09]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_fakeTimeout",
+"_fakeTimeoutPassing",
 smalltalk.method({
-selector: "fakeTimeout",
+selector: "fakeTimeoutPassing",
 category: 'helpers',
 fn: function (){
 var self=this;
-smalltalk.send(self,"_graceTime_",[(4)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_timeout_",[(20)]);
+return smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 return smalltalk.send(self,"_finished",[]);
+})]),"_valueWithTimeout_",[(10)]);
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "fakeTimeout\x0a\x09self graceTime: 4.\x0a    (self async: [ self finished ]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "finished"],
+source: "fakeTimeoutPassing\x0a\x09self timeout: 10.\x0a    (self async: [\x0a\x09\x09self timeout: 20.\x0a        (self async: [ self finished ]) valueWithTimeout: 10\x0a\x09]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
@@ -325,7 +325,7 @@ suite=smalltalk.send(["fakeError", "fakeErrorFailingInTearDown", "fakeFailure",
 return smalltalk.send(smalltalk.send(self,"_class",[]),"_selector_",[each]);
 })]);
 runner=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(self,"_graceTime_",[(200)]);
+smalltalk.send(self,"_timeout_",[(200)]);
 result=smalltalk.send(runner,"_result",[]);
 assertBlock=smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_equals_",[["fakeError"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_errors",[])])]);
@@ -346,16 +346,16 @@ smalltalk.send($1,"_on_do_",[$2,$3]);
 smalltalk.send(runner,"_run",[]);
 return self},
 args: [],
-source: "testAsyncErrorsAndFailures\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].\x0a    runner := TestSuiteRunner on: suite.\x0a    self graceTime: 200.\x0a\x09result := runner result.\x0a    assertBlock := self async: [\x0a\x09\x09self assert: #('fakeError') equals: (self sortedSelectors: result errors).\x0a\x09\x09self assert: #('fakeErrorFailingInTearDown' 'fakeFailure') equals: (self sortedSelectors: result failures).\x0a\x09\x09self finished\x0a  \x09].\x0a    runner announcer on: ResultAnnouncement do: [:ann |\x0a    \x09ann result == result  ifTrue: [ result runs = result total ifTrue: assertBlock ]].\x0a\x09runner run",
-messageSends: ["collect:", "selector:", "class", "on:", "graceTime:", "result", "async:", "assert:equals:", "sortedSelectors:", "errors", "failures", "finished", "on:do:", "ifTrue:", "=", "total", "runs", "==", "announcer", "run"],
+source: "testAsyncErrorsAndFailures\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].\x0a    runner := TestSuiteRunner on: suite.\x0a    self timeout: 200.\x0a\x09result := runner result.\x0a    assertBlock := self async: [\x0a\x09\x09self assert: #('fakeError') equals: (self sortedSelectors: result errors).\x0a\x09\x09self assert: #('fakeErrorFailingInTearDown' 'fakeFailure') equals: (self sortedSelectors: result failures).\x0a\x09\x09self finished\x0a  \x09].\x0a    runner announcer on: ResultAnnouncement do: [:ann |\x0a    \x09ann result == result  ifTrue: [ result runs = result total ifTrue: assertBlock ]].\x0a\x09runner run",
+messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "sortedSelectors:", "errors", "failures", "finished", "on:do:", "ifTrue:", "=", "total", "runs", "==", "announcer", "run"],
 referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"]
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_testAsyncNeedsGraceTime",
+"_testAsyncNeedsTimeout",
 smalltalk.method({
-selector: "testAsyncNeedsGraceTime",
+selector: "testAsyncNeedsTimeout",
 category: 'tests',
 fn: function (){
 var self=this;
@@ -363,7 +363,7 @@ smalltalk.send(self,"_should_raise_",[(function(){
 return smalltalk.send(self,"_async_",[(function(){
 })]);
 }),(smalltalk.Error || Error)]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_shouldnt_raise_",[(function(){
 return smalltalk.send(self,"_async_",[(function(){
 })]);
@@ -371,30 +371,30 @@ return smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_finished",[]);
 return self},
 args: [],
-source: "testAsyncNeedsGraceTime\x0a    self should: [ self async: [ ] ] raise: Error.\x0a    self graceTime: 0.\x0a    self shouldnt: [ self async: [ ] ] raise: Error.\x0a    self finished\x0a",
-messageSends: ["should:raise:", "async:", "graceTime:", "shouldnt:raise:", "finished"],
+source: "testAsyncNeedsTimeout\x0a    self should: [ self async: [ ] ] raise: Error.\x0a    self timeout: 0.\x0a    self shouldnt: [ self async: [ ] ] raise: Error.\x0a    self finished\x0a",
+messageSends: ["should:raise:", "async:", "timeout:", "shouldnt:raise:", "finished"],
 referencedClasses: ["Error"]
 }),
 smalltalk.SUnitAsyncTest);
 
 smalltalk.addMethod(
-"_testFinishedNeedsGraceTime",
+"_testFinishedNeedsTimeout",
 smalltalk.method({
-selector: "testFinishedNeedsGraceTime",
+selector: "testFinishedNeedsTimeout",
 category: 'tests',
 fn: function (){
 var self=this;
 smalltalk.send(self,"_should_raise_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 }),(smalltalk.Error || Error)]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_shouldnt_raise_",[(function(){
 return smalltalk.send(self,"_finished",[]);
 }),(smalltalk.Error || Error)]);
 return self},
 args: [],
-source: "testFinishedNeedsGraceTime\x0a    self should: [ self finished ] raise: Error.\x0a    self graceTime: 0.\x0a    self shouldnt: [ self finished ] raise: Error.\x0a",
-messageSends: ["should:raise:", "finished", "graceTime:", "shouldnt:raise:"],
+source: "testFinishedNeedsTimeout\x0a    self should: [ self finished ] raise: Error.\x0a    self timeout: 0.\x0a    self shouldnt: [ self finished ] raise: Error.\x0a",
+messageSends: ["should:raise:", "finished", "timeout:", "shouldnt:raise:"],
 referencedClasses: ["Error"]
 }),
 smalltalk.SUnitAsyncTest);
@@ -407,14 +407,14 @@ category: 'tests',
 fn: function (){
 var self=this;
 smalltalk.send(self,"_deny_",[smalltalk.send(self,"_isAsync",[])]);
-smalltalk.send(self,"_graceTime_",[(0)]);
+smalltalk.send(self,"_timeout_",[(0)]);
 smalltalk.send(self,"_assert_",[smalltalk.send(self,"_isAsync",[])]);
 smalltalk.send(self,"_finished",[]);
 smalltalk.send(self,"_deny_",[smalltalk.send(self,"_isAsync",[])]);
 return self},
 args: [],
-source: "testIsAsyncReturnsCorrectValues\x0a    self deny: self isAsync.\x0a    self graceTime: 0.\x0a    self assert: self isAsync.\x0a    self finished.\x0a    self deny: self isAsync\x0a",
-messageSends: ["deny:", "isAsync", "graceTime:", "assert:", "finished"],
+source: "testIsAsyncReturnsCorrectValues\x0a    self deny: self isAsync.\x0a    self timeout: 0.\x0a    self assert: self isAsync.\x0a    self finished.\x0a    self deny: self isAsync\x0a",
+messageSends: ["deny:", "isAsync", "timeout:", "assert:", "finished"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
@@ -427,7 +427,7 @@ category: 'tests',
 fn: function (){
 var self=this;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_",[true]);
 smalltalk.send(self,"_finished",[]);
@@ -436,8 +436,8 @@ return self["@flag"];
 })]),"_valueWithTimeout_",[(5)]);
 return self},
 args: [],
-source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self graceTime: 10.\x0a    flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "assert:", "finished"],
+source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a    flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:", "finished"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
@@ -454,15 +454,15 @@ var suite;
 var runner;
 var result;
 var assertBlock;
-suite=smalltalk.send(["fakeTimeout", "fakeMultipleGraceTimeFailing", "fakeMultipleGraceTimePassing", "testPass"],"_collect_",[(function(each){
+suite=smalltalk.send(["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"],"_collect_",[(function(each){
 return smalltalk.send(smalltalk.send(self,"_class",[]),"_selector_",[each]);
 })]);
 runner=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
-smalltalk.send(self,"_graceTime_",[(200)]);
+smalltalk.send(self,"_timeout_",[(200)]);
 result=smalltalk.send(runner,"_result",[]);
 assertBlock=smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[])]);
-smalltalk.send(self,"_assert_equals_",[["fakeMultipleGraceTimeFailing", "fakeTimeout"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_failures",[])])]);
+smalltalk.send(self,"_assert_equals_",[["fakeMultipleTimeoutFailing", "fakeTimeout"],smalltalk.send(self,"_sortedSelectors_",[smalltalk.send(result,"_failures",[])])]);
 return smalltalk.send(self,"_finished",[]);
 })]);
 $1=smalltalk.send(runner,"_announcer",[]);
@@ -479,8 +479,8 @@ smalltalk.send($1,"_on_do_",[$2,$3]);
 smalltalk.send(runner,"_run",[]);
 return self},
 args: [],
-source: "testTimeouts\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeTimeout' 'fakeMultipleGraceTimeFailing' 'fakeMultipleGraceTimePassing' 'testPass') collect: [ :each | self class selector: each ].\x0a    runner := TestSuiteRunner on: suite.\x0a    self graceTime: 200.\x0a\x09result := runner result.\x0a    assertBlock := self async: [\x0a\x09\x09self assert: result errors isEmpty.\x0a\x09\x09self assert: #('fakeMultipleGraceTimeFailing' 'fakeTimeout') equals: (self sortedSelectors: result failures).\x0a\x09\x09self finished\x0a  \x09].\x0a    runner announcer on: ResultAnnouncement do: [:ann |\x0a    \x09ann result == result  ifTrue: [ result runs = result total ifTrue: assertBlock ]].\x0a\x09runner run",
-messageSends: ["collect:", "selector:", "class", "on:", "graceTime:", "result", "async:", "assert:", "isEmpty", "errors", "assert:equals:", "sortedSelectors:", "failures", "finished", "on:do:", "ifTrue:", "=", "total", "runs", "==", "announcer", "run"],
+source: "testTimeouts\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeTimeout' 'fakeMultipleTimeoutFailing' 'fakeMultipleTimeoutPassing' 'testPass') collect: [ :each | self class selector: each ].\x0a    runner := TestSuiteRunner on: suite.\x0a    self timeout: 200.\x0a\x09result := runner result.\x0a    assertBlock := self async: [\x0a\x09\x09self assert: result errors isEmpty.\x0a\x09\x09self assert: #('fakeMultipleTimeoutFailing' 'fakeTimeout') equals: (self sortedSelectors: result failures).\x0a\x09\x09self finished\x0a  \x09].\x0a    runner announcer on: ResultAnnouncement do: [:ann |\x0a    \x09ann result == result  ifTrue: [ result runs = result total ifTrue: assertBlock ]].\x0a\x09runner run",
+messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:", "isEmpty", "errors", "assert:equals:", "sortedSelectors:", "failures", "finished", "on:do:", "ifTrue:", "=", "total", "runs", "==", "announcer", "run"],
 referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"]
 }),
 smalltalk.SUnitAsyncTest);
@@ -494,7 +494,7 @@ fn: function (){
 var self=this;
 var x;
 self["@flag"]="bad";
-smalltalk.send(self,"_graceTime_",[(10)]);
+smalltalk.send(self,"_timeout_",[(10)]);
 x=(0);
 self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
 smalltalk.send(self,"_finished",[]);
@@ -514,8 +514,8 @@ return smalltalk.send(self,"_assert_equals_",[(1),x]);
 })]),"_valueWithTimeout_",[(0)]);
 return self},
 args: [],
-source: "testTwoAsyncPassesWithFinishedOnlyOneIsRun\x0a\x09| x |\x0a\x09flag := 'bad'.\x0a\x09self graceTime: 10.\x0a    x := 0.\x0a    flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.\x0a    flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.\x0a",
-messageSends: ["graceTime:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"],
+source: "testTwoAsyncPassesWithFinishedOnlyOneIsRun\x0a\x09| x |\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a    x := 0.\x0a    flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.\x0a    flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.\x0a",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"],
 referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);

+ 22 - 22
js/SUnit.deploy.js

@@ -118,7 +118,7 @@ var self=this;
 var $1;
 $1=smalltalk.send(self,"_isAsync",[]);
 if(! smalltalk.assert($1)){
-smalltalk.send(self,"_error_",[smalltalk.send(aString,"__comma",[" used without prior #graceTime:"])]);
+smalltalk.send(self,"_error_",[smalltalk.send(aString,"__comma",[" used without prior #timeout:"])]);
 };
 return self}
 }),
@@ -136,27 +136,6 @@ return self}
 }),
 smalltalk.TestCase);
 
-smalltalk.addMethod(
-"_graceTime_",
-smalltalk.method({
-selector: "graceTime:",
-fn: function (millis){
-var self=this;
-var $1;
-$1=self["@asyncTimeout"];
-if(($receiver = $1) == nil || $receiver == undefined){
-$1;
-} else {
-smalltalk.send(self["@asyncTimeout"],"_clearTimeout",[]);
-};
-self["@asyncTimeout"]=true;
-self["@asyncTimeout"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-return smalltalk.send(self,"_assert_description_",[false,"SUnit grace time exhausted"]);
-})]),"_valueWithTimeout_",[millis]);
-return self}
-}),
-smalltalk.TestCase);
-
 smalltalk.addMethod(
 "_isAsync",
 smalltalk.method({
@@ -294,6 +273,27 @@ return self}
 }),
 smalltalk.TestCase);
 
+smalltalk.addMethod(
+"_timeout_",
+smalltalk.method({
+selector: "timeout:",
+fn: function (aNumber){
+var self=this;
+var $1;
+$1=self["@asyncTimeout"];
+if(($receiver = $1) == nil || $receiver == undefined){
+$1;
+} else {
+smalltalk.send(self["@asyncTimeout"],"_clearTimeout",[]);
+};
+self["@asyncTimeout"]=(0);
+self["@asyncTimeout"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+return smalltalk.send(self,"_assert_description_",[false,"SUnit grace time exhausted"]);
+})]),"_valueWithTimeout_",[aNumber]);
+return self}
+}),
+smalltalk.TestCase);
+
 
 smalltalk.addMethod(
 "_allTestSelectors",

+ 28 - 28
js/SUnit.js

@@ -160,11 +160,11 @@ var self=this;
 var $1;
 $1=smalltalk.send(self,"_isAsync",[]);
 if(! smalltalk.assert($1)){
-smalltalk.send(self,"_error_",[smalltalk.send(aString,"__comma",[" used without prior #graceTime:"])]);
+smalltalk.send(self,"_error_",[smalltalk.send(aString,"__comma",[" used without prior #timeout:"])]);
 };
 return self},
 args: ["aString"],
-source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [ \x0a    \x09self error: aString, ' used without prior #graceTime:' ]",
+source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [ \x0a    \x09self error: aString, ' used without prior #timeout:' ]",
 messageSends: ["ifFalse:", "error:", ",", "isAsync"],
 referencedClasses: []
 }),
@@ -187,32 +187,6 @@ referencedClasses: []
 }),
 smalltalk.TestCase);
 
-smalltalk.addMethod(
-"_graceTime_",
-smalltalk.method({
-selector: "graceTime:",
-category: 'async',
-fn: function (millis){
-var self=this;
-var $1;
-$1=self["@asyncTimeout"];
-if(($receiver = $1) == nil || $receiver == undefined){
-$1;
-} else {
-smalltalk.send(self["@asyncTimeout"],"_clearTimeout",[]);
-};
-self["@asyncTimeout"]=true;
-self["@asyncTimeout"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
-return smalltalk.send(self,"_assert_description_",[false,"SUnit grace time exhausted"]);
-})]),"_valueWithTimeout_",[millis]);
-return self},
-args: ["millis"],
-source: "graceTime: millis\x0a\x09asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].\x0a\x09asyncTimeout := true. \x22to allow async:\x22\x0a\x09asyncTimeout :=\x0a\x09\x09(self async: [ self assert: false description: 'SUnit grace time exhausted' ])\x0a        valueWithTimeout: millis",
-messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"],
-referencedClasses: []
-}),
-smalltalk.TestCase);
-
 smalltalk.addMethod(
 "_isAsync",
 smalltalk.method({
@@ -405,6 +379,32 @@ referencedClasses: []
 }),
 smalltalk.TestCase);
 
+smalltalk.addMethod(
+"_timeout_",
+smalltalk.method({
+selector: "timeout:",
+category: 'async',
+fn: function (aNumber){
+var self=this;
+var $1;
+$1=self["@asyncTimeout"];
+if(($receiver = $1) == nil || $receiver == undefined){
+$1;
+} else {
+smalltalk.send(self["@asyncTimeout"],"_clearTimeout",[]);
+};
+self["@asyncTimeout"]=(0);
+self["@asyncTimeout"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+return smalltalk.send(self,"_assert_description_",[false,"SUnit grace time exhausted"]);
+})]),"_valueWithTimeout_",[aNumber]);
+return self},
+args: ["aNumber"],
+source: "timeout: aNumber\x0a\x09\x22Set a grace time timeout in milliseconds to run the test asynchronously\x22\x0a    \x0a\x09asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].\x0a    \x0a     \x22to allow #async: message send without throwing an error\x22\x0a\x09asyncTimeout := 0.\x0a    \x0a\x09asyncTimeout := (self async: [ \x0a    \x09self assert: false description: 'SUnit grace time exhausted' ])\x0a        \x09valueWithTimeout: aNumber",
+messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"],
+referencedClasses: []
+}),
+smalltalk.TestCase);
+
 
 smalltalk.addMethod(
 "_allTestSelectors",

+ 25 - 25
st/SUnit-Tests.st

@@ -61,41 +61,41 @@ TestCase subclass: #SUnitAsyncTest
 
 fakeError
 	flag := 'bad'.
-	self graceTime: 10.
+	self timeout: 10.
     flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 5
 !
 
 fakeErrorFailingInTearDown
 	flag := 'bad'.
-	self graceTime: 10.
+	self timeout: 10.
     flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 5
 !
 
 fakeFailure
 	flag := 'bad'.
-	self graceTime: 10.
+	self timeout: 10.
     flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 5
 !
 
-fakeMultipleGraceTimeFailing
-	self graceTime: 100.
+fakeTimeout
+	self timeout: 4.
+    (self async: [ self finished ]) valueWithTimeout: 5
+!
+
+fakeTimeoutFailing
+	self timeout: 100.
     (self async: [
-		self graceTime: 5.
+		self timeout: 5.
         (self async: [ self finished ]) valueWithTimeout: 10
 	]) valueWithTimeout: 5
 !
 
-fakeMultipleGraceTimePassing
-	self graceTime: 10.
+fakeTimeoutPassing
+	self timeout: 10.
     (self async: [
-		self graceTime: 20.
+		self timeout: 20.
         (self async: [ self finished ]) valueWithTimeout: 10
 	]) valueWithTimeout: 5
-!
-
-fakeTimeout
-	self graceTime: 4.
-    (self async: [ self finished ]) valueWithTimeout: 5
 ! !
 
 !SUnitAsyncTest methodsFor: 'private'!
@@ -120,7 +120,7 @@ testAsyncErrorsAndFailures
 	| suite runner result assertBlock |
 	suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].
     runner := TestSuiteRunner on: suite.
-    self graceTime: 200.
+    self timeout: 200.
 	result := runner result.
     assertBlock := self async: [
 		self assert: #('fakeError') equals: (self sortedSelectors: result errors).
@@ -132,22 +132,22 @@ testAsyncErrorsAndFailures
 	runner run
 !
 
-testAsyncNeedsGraceTime
+testAsyncNeedsTimeout
     self should: [ self async: [ ] ] raise: Error.
-    self graceTime: 0.
+    self timeout: 0.
     self shouldnt: [ self async: [ ] ] raise: Error.
     self finished
 !
 
-testFinishedNeedsGraceTime
+testFinishedNeedsTimeout
     self should: [ self finished ] raise: Error.
-    self graceTime: 0.
+    self timeout: 0.
     self shouldnt: [ self finished ] raise: Error.
 !
 
 testIsAsyncReturnsCorrectValues
     self deny: self isAsync.
-    self graceTime: 0.
+    self timeout: 0.
     self assert: self isAsync.
     self finished.
     self deny: self isAsync
@@ -155,19 +155,19 @@ testIsAsyncReturnsCorrectValues
 
 testPass
 	flag := 'bad'.
-	self graceTime: 10.
+	self timeout: 10.
     flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5
 !
 
 testTimeouts
 	| suite runner result assertBlock |
-	suite := #('fakeTimeout' 'fakeMultipleGraceTimeFailing' 'fakeMultipleGraceTimePassing' 'testPass') collect: [ :each | self class selector: each ].
+	suite := #('fakeTimeout' 'fakeMultipleTimeoutFailing' 'fakeMultipleTimeoutPassing' 'testPass') collect: [ :each | self class selector: each ].
     runner := TestSuiteRunner on: suite.
-    self graceTime: 200.
+    self timeout: 200.
 	result := runner result.
     assertBlock := self async: [
 		self assert: result errors isEmpty.
-		self assert: #('fakeMultipleGraceTimeFailing' 'fakeTimeout') equals: (self sortedSelectors: result failures).
+		self assert: #('fakeMultipleTimeoutFailing' 'fakeTimeout') equals: (self sortedSelectors: result failures).
 		self finished
   	].
     runner announcer on: ResultAnnouncement do: [:ann |
@@ -178,7 +178,7 @@ testTimeouts
 testTwoAsyncPassesWithFinishedOnlyOneIsRun
 	| x |
 	flag := 'bad'.
-	self graceTime: 10.
+	self timeout: 10.
     x := 0.
     flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.
     flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.

+ 11 - 6
st/SUnit.st

@@ -55,19 +55,24 @@ finished
 	asyncTimeout := nil
 !
 
-graceTime: millis
+timeout: aNumber
+	"Set a grace time timeout in milliseconds to run the test asynchronously"
+    
 	asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].
-	asyncTimeout := true. "to allow async:"
-	asyncTimeout :=
-		(self async: [ self assert: false description: 'SUnit grace time exhausted' ])
-        valueWithTimeout: millis
+    
+     "to allow #async: message send without throwing an error"
+	asyncTimeout := 0.
+    
+	asyncTimeout := (self async: [ 
+    	self assert: false description: 'SUnit grace time exhausted' ])
+        	valueWithTimeout: aNumber
 ! !
 
 !TestCase methodsFor: 'error handling'!
 
 errorIfNotAsync: aString
 	self isAsync ifFalse: [ 
-    	self error: aString, ' used without prior #graceTime:' ]
+    	self error: aString, ' used without prior #timeout:' ]
 ! !
 
 !TestCase methodsFor: 'private'!