1
0
Quellcode durchsuchen

Test for BlockClosure exception semantics

Nicolas Petton vor 12 Jahren
Ursprung
Commit
020ff0ee2b
3 geänderte Dateien mit 62 neuen und 0 gelöschten Zeilen
  1. 21 0
      js/Kernel-Tests.deploy.js
  2. 26 0
      js/Kernel-Tests.js
  3. 15 0
      st/Kernel-Tests.st

+ 21 - 0
js/Kernel-Tests.deploy.js

@@ -75,6 +75,27 @@ return self}, function($ctx1) {$ctx1.fill(self,"testEnsureRaises",{}, smalltalk.
 }),
 smalltalk.BlockClosureTest);
 
+smalltalk.addMethod(
+"_testExceptionSemantics",
+smalltalk.method({
+selector: "testExceptionSemantics",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._timeout_((100));
+_st(_st(self)._async_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st((function(){
+return smalltalk.withContext(function($ctx3) {
_st(self)._assert_(true);
+_st((smalltalk.Error || Error))._signal();
+_st(self)._deny_(true);
+return _st(self)._finished();
+}, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
+return smalltalk.withContext(function($ctx3) {
return _st(self)._finished();
+}, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((0));
+return self}, function($ctx1) {$ctx1.fill(self,"testExceptionSemantics",{}, smalltalk.BlockClosureTest)})}
+}),
+smalltalk.BlockClosureTest);
+
 smalltalk.addMethod(
 "_testNumArgs",
 smalltalk.method({

+ 26 - 0
js/Kernel-Tests.js

@@ -100,6 +100,32 @@ referencedClasses: ["Error"]
 }),
 smalltalk.BlockClosureTest);
 
+smalltalk.addMethod(
+"_testExceptionSemantics",
+smalltalk.method({
+selector: "testExceptionSemantics",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._timeout_((100));
+_st(_st(self)._async_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st((function(){
+return smalltalk.withContext(function($ctx3) {
_st(self)._assert_(true);
+_st((smalltalk.Error || Error))._signal();
+_st(self)._deny_(true);
+return _st(self)._finished();
+}, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
+return smalltalk.withContext(function($ctx3) {
return _st(self)._finished();
+}, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((0));
+return self}, function($ctx1) {$ctx1.fill(self,"testExceptionSemantics",{}, smalltalk.BlockClosureTest)})},
+args: [],
+source: "testExceptionSemantics\x0a\x09\x22See https://github.com/NicolasPetton/amber/issues/314\x22\x0a    self timeout: 100.\x0a    \x0a    (self async:  [ \x0a    \x09[ \x0a        \x09self assert: true. \x0a            Error signal. \x0a            \x22The following should *not* be run\x22\x0a            self deny: true.\x0a            self finished.\x0a  \x09\x09] on: Error do: [ :ex | self finished ] \x0a\x09]) valueWithTimeout: 0",
+messageSends: ["timeout:", "valueWithTimeout:", "async:", "on:do:", "finished", "assert:", "signal", "deny:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.BlockClosureTest);
+
 smalltalk.addMethod(
 "_testNumArgs",
 smalltalk.method({

+ 15 - 0
st/Kernel-Tests.st

@@ -25,6 +25,21 @@ testEnsureRaises
 	self should: [[Error new signal] ensure: [true]] raise: Error
 !
 
+testExceptionSemantics
+	"See https://github.com/NicolasPetton/amber/issues/314"
+    self timeout: 100.
+    
+    (self async:  [ 
+    	[ 
+        	self assert: true. 
+            Error signal. 
+            "The following should *not* be run"
+            self deny: true.
+            self finished.
+  		] on: Error do: [ :ex | self finished ] 
+	]) valueWithTimeout: 0
+!
+
 testNumArgs
 	self assert: [] numArgs equals: 0.
 	self assert: [:a :b | ] numArgs equals: 2