Selaa lähdekoodia

#async: block of finished test not run.

Herby Vojčík 11 vuotta sitten
vanhempi
commit
fb228e3276
6 muutettua tiedostoa jossa 85 lisäystä ja 5 poistoa
  1. 30 0
      js/SUnit-Tests.deploy.js
  2. 35 0
      js/SUnit-Tests.js
  3. 4 1
      js/SUnit.deploy.js
  4. 6 3
      js/SUnit.js
  5. 9 0
      st/SUnit-Tests.st
  6. 1 1
      st/SUnit.st

+ 30 - 0
js/SUnit-Tests.deploy.js

@@ -190,5 +190,35 @@ return self}
 }),
 smalltalk.SUnitAsyncTest);
 
+smalltalk.addMethod(
+"_testTwoAsyncPassesWithFinishedOnlyOneIsRun",
+smalltalk.method({
+selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
+fn: function (){
+var self=this;
+var x;
+self["@flag"]="bad";
+smalltalk.send(self,"_graceTime_",[(10)]);
+x=(0);
+self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_finished",[]);
+self["@flag"]="ok";
+self["@flag"];
+x=smalltalk.send(x,"__plus",[(1)]);
+x;
+return smalltalk.send(self,"_assert_equals_",[(1),x]);
+})]),"_valueWithTimeout_",[(0)]);
+self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_finished",[]);
+self["@flag"]="ok";
+self["@flag"];
+x=smalltalk.send(x,"__plus",[(1)]);
+x;
+return smalltalk.send(self,"_assert_equals_",[(1),x]);
+})]),"_valueWithTimeout_",[(0)]);
+return self}
+}),
+smalltalk.SUnitAsyncTest);
+
 
 

+ 35 - 0
js/SUnit-Tests.js

@@ -245,5 +245,40 @@ referencedClasses: []
 }),
 smalltalk.SUnitAsyncTest);
 
+smalltalk.addMethod(
+"_testTwoAsyncPassesWithFinishedOnlyOneIsRun",
+smalltalk.method({
+selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
+category: 'tests',
+fn: function (){
+var self=this;
+var x;
+self["@flag"]="bad";
+smalltalk.send(self,"_graceTime_",[(10)]);
+x=(0);
+self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_finished",[]);
+self["@flag"]="ok";
+self["@flag"];
+x=smalltalk.send(x,"__plus",[(1)]);
+x;
+return smalltalk.send(self,"_assert_equals_",[(1),x]);
+})]),"_valueWithTimeout_",[(0)]);
+self["@flag"]=smalltalk.send(smalltalk.send(self,"_async_",[(function(){
+smalltalk.send(self,"_finished",[]);
+self["@flag"]="ok";
+self["@flag"];
+x=smalltalk.send(x,"__plus",[(1)]);
+x;
+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:"],
+referencedClasses: []
+}),
+smalltalk.SUnitAsyncTest);
+
 
 

+ 4 - 1
js/SUnit.deploy.js

@@ -205,12 +205,15 @@ smalltalk.method({
 selector: "async:",
 fn: function (aBlock){
 var self=this;
-var $1;
+var $2,$1;
 var c;
 smalltalk.send(self,"_mustBeAsync_",["#async"]);
 c=self["@context"];
 $1=(function(){
+$2=smalltalk.send(self,"_isAsync",[]);
+if(smalltalk.assert($2)){
 return smalltalk.send(c,"_execute_",[aBlock]);
+};
 });
 return $1;
 }

+ 6 - 3
js/SUnit.js

@@ -266,18 +266,21 @@ selector: "async:",
 category: 'async',
 fn: function (aBlock){
 var self=this;
-var $1;
+var $2,$1;
 var c;
 smalltalk.send(self,"_mustBeAsync_",["#async"]);
 c=self["@context"];
 $1=(function(){
+$2=smalltalk.send(self,"_isAsync",[]);
+if(smalltalk.assert($2)){
 return smalltalk.send(c,"_execute_",[aBlock]);
+};
 });
 return $1;
 },
 args: ["aBlock"],
-source: "async: aBlock\x0a\x09| c |\x0a\x09self mustBeAsync: '#async'.\x0a    c := context.\x0a    ^[ c execute: aBlock ]",
-messageSends: ["mustBeAsync:", "execute:"],
+source: "async: aBlock\x0a\x09| c |\x0a\x09self mustBeAsync: '#async'.\x0a    c := context.\x0a    ^[ self isAsync ifTrue: [ c execute: aBlock ]]",
+messageSends: ["mustBeAsync:", "ifTrue:", "execute:", "isAsync"],
 referencedClasses: []
 }),
 smalltalk.TestCase);

+ 9 - 0
st/SUnit-Tests.st

@@ -80,5 +80,14 @@ testPass
 	flag := 'bad'.
 	self graceTime: 10.
     flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5
+!
+
+testTwoAsyncPassesWithFinishedOnlyOneIsRun
+	| x |
+	flag := 'bad'.
+	self graceTime: 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.
 ! !
 

+ 1 - 1
st/SUnit.st

@@ -90,7 +90,7 @@ async: aBlock
 	| c |
 	self mustBeAsync: '#async'.
     c := context.
-    ^[ c execute: aBlock ]
+    ^[ self isAsync ifTrue: [ c execute: aBlock ]]
 !
 
 finished