|
@@ -34,29 +34,19 @@ smalltalk.ResultAnnouncement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-smalltalk.addClass('RunningTestContext', smalltalk.Object, ['finished', 'testCase', 'result', 'step'], 'SUnit');
|
|
|
|
|
|
+smalltalk.addClass('RunningTestContext', smalltalk.Object, ['finished', 'testCase', 'result'], 'SUnit');
|
|
smalltalk.addMethod(
|
|
smalltalk.addMethod(
|
|
-"_exception_ifNotAsync_",
|
|
|
|
|
|
+"_exception_do_",
|
|
smalltalk.method({
|
|
smalltalk.method({
|
|
-selector: "exception:ifNotAsync:",
|
|
|
|
|
|
+selector: "exception:do:",
|
|
category: 'private',
|
|
category: 'private',
|
|
fn: function (anException,aBlock){
|
|
fn: function (anException,aBlock){
|
|
var self=this;
|
|
var self=this;
|
|
-var $1;
|
|
|
|
-$1=smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
-if(smalltalk.assert($1)){
|
|
|
|
-self["@step"]=(function(){
|
|
|
|
-smalltalk.send(self["@testCase"],"_finished",[]);
|
|
|
|
-return smalltalk.send(anException,"_signal",[]);
|
|
|
|
-});
|
|
|
|
-self["@step"];
|
|
|
|
-} else {
|
|
|
|
smalltalk.send(aBlock,"_value",[]);
|
|
smalltalk.send(aBlock,"_value",[]);
|
|
-};
|
|
|
|
return self},
|
|
return self},
|
|
args: ["anException", "aBlock"],
|
|
args: ["anException", "aBlock"],
|
|
-source: "exception: anException ifNotAsync: aBlock\x0a\x09testCase isAsync\x0a\x09\x09ifTrue: [ step := [ testCase finished. anException signal ]]\x0a\x09\x09ifFalse: [ aBlock value ]\x0a",
|
|
|
|
-messageSends: ["ifTrue:ifFalse:", "finished", "signal", "value", "isAsync"],
|
|
|
|
|
|
+source: "exception: anException do: aBlock\x0a\x09aBlock value\x0a",
|
|
|
|
+messageSends: ["value"],
|
|
referencedClasses: []
|
|
referencedClasses: []
|
|
}),
|
|
}),
|
|
smalltalk.RunningTestContext);
|
|
smalltalk.RunningTestContext);
|
|
@@ -68,50 +58,77 @@ selector: "execute:",
|
|
category: 'running',
|
|
category: 'running',
|
|
fn: function (aBlock){
|
|
fn: function (aBlock){
|
|
var self=this;
|
|
var self=this;
|
|
-var $1,$2;
|
|
|
|
-self["@step"]=aBlock;
|
|
|
|
-smalltalk.send((function(){
|
|
|
|
-return smalltalk.send(self["@step"],"_isNil",[]);
|
|
|
|
-}),"_whileFalse_",[(function(){
|
|
|
|
-smalltalk.send(self["@testCase"],"_context_",[self]);
|
|
|
|
-return smalltalk.send((function(){
|
|
|
|
|
|
+var $1,$3,$2;
|
|
|
|
+$1=(function(){
|
|
return smalltalk.send((function(){
|
|
return smalltalk.send((function(){
|
|
return smalltalk.send((function(){
|
|
return smalltalk.send((function(){
|
|
-return smalltalk.send(self["@step"],"_ensure_",[(function(){
|
|
|
|
-smalltalk.send(self["@testCase"],"_context_",[nil]);
|
|
|
|
-self["@step"]=nil;
|
|
|
|
-self["@step"];
|
|
|
|
-$1=smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
-if(! smalltalk.assert($1)){
|
|
|
|
-return smalltalk.send(self["@testCase"],"_tearDown",[]);
|
|
|
|
-};
|
|
|
|
-})]);
|
|
|
|
|
|
+return smalltalk.send(self,"_executeWithCleanup_",[aBlock]);
|
|
}),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
|
|
}),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
|
|
-return smalltalk.send(self,"_exception_ifNotAsync_",[ex,(function(){
|
|
|
|
|
|
+return smalltalk.send(self,"_exception_do_",[ex,(function(){
|
|
return smalltalk.send(self["@result"],"_addFailure_",[self["@testCase"]]);
|
|
return smalltalk.send(self["@result"],"_addFailure_",[self["@testCase"]]);
|
|
})]);
|
|
})]);
|
|
})]);
|
|
})]);
|
|
}),"_on_do_",[(smalltalk.Error || Error),(function(ex){
|
|
}),"_on_do_",[(smalltalk.Error || Error),(function(ex){
|
|
-return smalltalk.send(self,"_exception_ifNotAsync_",[ex,(function(){
|
|
|
|
|
|
+return smalltalk.send(self,"_exception_do_",[ex,(function(){
|
|
return smalltalk.send(self["@result"],"_addError_",[self["@testCase"]]);
|
|
return smalltalk.send(self["@result"],"_addError_",[self["@testCase"]]);
|
|
})]);
|
|
})]);
|
|
})]);
|
|
})]);
|
|
-}),"_ensure_",[(function(){
|
|
|
|
-$2=smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
-if(! smalltalk.assert($2)){
|
|
|
|
|
|
+});
|
|
|
|
+$2=(function(){
|
|
|
|
+$3=smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
+if(! smalltalk.assert($3)){
|
|
smalltalk.send(self["@result"],"_increaseRuns",[]);
|
|
smalltalk.send(self["@result"],"_increaseRuns",[]);
|
|
return smalltalk.send(self["@finished"],"_value",[]);
|
|
return smalltalk.send(self["@finished"],"_value",[]);
|
|
};
|
|
};
|
|
-})]);
|
|
|
|
-})]);
|
|
|
|
|
|
+});
|
|
|
|
+smalltalk.send($1,"_ensure_",[$2]);
|
|
return self},
|
|
return self},
|
|
args: ["aBlock"],
|
|
args: ["aBlock"],
|
|
-source: "execute: aBlock\x0a step := aBlock.\x0a\x09[ step isNil ] whileFalse: [\x0a\x09 testCase context: self.\x0a\x09\x09[[[\x09step\x0a \x09\x09ensure: [ testCase context: nil. step := nil. testCase isAsync ifFalse: [ testCase tearDown ]]]\x0a\x09\x09\x09\x09on: TestFailure do: [:ex | self exception: ex ifNotAsync: [ result addFailure: testCase]]]\x0a\x09\x09\x09\x09on: Error do: [:ex | self exception: ex ifNotAsync: [ result addError: testCase]]]\x0a\x09\x09\x09\x09ensure: [ testCase isAsync ifFalse: [ result increaseRuns. finished value ]]]",
|
|
|
|
-messageSends: ["whileFalse:", "context:", "ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "on:do:", "exception:ifNotAsync:", "addError:", "addFailure:", "tearDown", "isNil"],
|
|
|
|
|
|
+source: "execute: aBlock\x0a [[[ self executeWithCleanup: aBlock ]\x0a on: TestFailure do: [:ex | self exception: ex do: [ result addFailure: testCase]]]\x0a on: Error do: [:ex | self exception: ex do: [ result addError: testCase]]]\x0a ensure: [ testCase isAsync ifFalse: [ result increaseRuns. finished value ]]",
|
|
|
|
+messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "on:do:", "exception:do:", "addError:", "addFailure:", "executeWithCleanup:"],
|
|
referencedClasses: ["Error", "TestFailure"]
|
|
referencedClasses: ["Error", "TestFailure"]
|
|
}),
|
|
}),
|
|
smalltalk.RunningTestContext);
|
|
smalltalk.RunningTestContext);
|
|
|
|
|
|
|
|
+smalltalk.addMethod(
|
|
|
|
+"_executeWithCleanup_",
|
|
|
|
+smalltalk.method({
|
|
|
|
+selector: "executeWithCleanup:",
|
|
|
|
+category: 'private',
|
|
|
|
+fn: function (aBlock){
|
|
|
|
+var self=this;
|
|
|
|
+var $1,$3,$4,$2;
|
|
|
|
+var failed;
|
|
|
|
+smalltalk.send(self["@testCase"],"_context_",[self]);
|
|
|
|
+$1=(function(){
|
|
|
|
+failed=true;
|
|
|
|
+failed;
|
|
|
|
+smalltalk.send(aBlock,"_value",[]);
|
|
|
|
+failed=false;
|
|
|
|
+return failed;
|
|
|
|
+});
|
|
|
|
+$2=(function(){
|
|
|
|
+smalltalk.send(self["@testCase"],"_context_",[nil]);
|
|
|
|
+$3=smalltalk.send(failed,"_and_",[(function(){
|
|
|
|
+return smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
+})]);
|
|
|
|
+if(smalltalk.assert($3)){
|
|
|
|
+smalltalk.send(self["@testCase"],"_finished",[]);
|
|
|
|
+};
|
|
|
|
+$4=smalltalk.send(self["@testCase"],"_isAsync",[]);
|
|
|
|
+if(! smalltalk.assert($4)){
|
|
|
|
+return smalltalk.send(self["@testCase"],"_tearDown",[]);
|
|
|
|
+};
|
|
|
|
+});
|
|
|
|
+smalltalk.send($1,"_ensure_",[$2]);
|
|
|
|
+return self},
|
|
|
|
+args: ["aBlock"],
|
|
|
|
+source: "executeWithCleanup: aBlock\x0a\x09| failed |\x0a testCase context: self.\x0a [ failed := true. aBlock value. failed := false ] ensure: [\x0a testCase context: nil.\x0a (failed and: [testCase isAsync]) ifTrue: [ testCase finished ].\x0a testCase isAsync ifFalse: [ testCase tearDown ]\x0a ]\x0a",
|
|
|
|
+messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"],
|
|
|
|
+referencedClasses: []
|
|
|
|
+}),
|
|
|
|
+smalltalk.RunningTestContext);
|
|
|
|
+
|
|
smalltalk.addMethod(
|
|
smalltalk.addMethod(
|
|
"_finished_",
|
|
"_finished_",
|
|
smalltalk.method({
|
|
smalltalk.method({
|
|
@@ -206,16 +223,16 @@ smalltalk.RunningTestContext.klass);
|
|
|
|
|
|
smalltalk.addClass('ErroringTestContext', smalltalk.RunningTestContext, [], 'SUnit');
|
|
smalltalk.addClass('ErroringTestContext', smalltalk.RunningTestContext, [], 'SUnit');
|
|
smalltalk.addMethod(
|
|
smalltalk.addMethod(
|
|
-"_exception_ifNotAsync_",
|
|
|
|
|
|
+"_exception_do_",
|
|
smalltalk.method({
|
|
smalltalk.method({
|
|
-selector: "exception:ifNotAsync:",
|
|
|
|
|
|
+selector: "exception:do:",
|
|
category: 'private',
|
|
category: 'private',
|
|
fn: function (anException,aBlock){
|
|
fn: function (anException,aBlock){
|
|
var self=this;
|
|
var self=this;
|
|
smalltalk.send(anException,"_signal",[]);
|
|
smalltalk.send(anException,"_signal",[]);
|
|
return self},
|
|
return self},
|
|
args: ["anException", "aBlock"],
|
|
args: ["anException", "aBlock"],
|
|
-source: "exception: anException ifNotAsync: aBlock\x0a\x09anException signal",
|
|
|
|
|
|
+source: "exception: anException do: aBlock\x0a\x09anException signal",
|
|
messageSends: ["signal"],
|
|
messageSends: ["signal"],
|
|
referencedClasses: []
|
|
referencedClasses: []
|
|
}),
|
|
}),
|