Browse Source

Test for #isError.

Helps inter-context error handling.

Read: test failures are shown correctly in Helios.
Herby Vojčík 4 years ago
parent
commit
2a02bf0789

+ 18 - 0
lang/src/Kernel-Exceptions.js

@@ -150,6 +150,24 @@ return self;
 }; }),
 $globals.Error);
 
+$core.addMethod(
+$core.method({
+selector: "isError",
+protocol: "testing",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isError\x0a\x09^ true",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+return true;
+
+}; }),
+$globals.Error);
+
 $core.addMethod(
 $core.method({
 selector: "isSmalltalkError",

+ 4 - 0
lang/src/Kernel-Exceptions.st

@@ -100,6 +100,10 @@ signal: aString
 
 !Error methodsFor: 'testing'!
 
+isError
+	^ true
+!
+
 isSmalltalkError
 	^ smalltalkError == true
 !

+ 18 - 0
lang/src/Kernel-Helpers.js

@@ -80,6 +80,24 @@ return false;
 }; }),
 $globals.TIsInGroup);
 
+$core.addMethod(
+$core.method({
+selector: "isError",
+protocol: "testing",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isError\x0a\x09^ false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+return false;
+
+}; }),
+$globals.TIsInGroup);
+
 $core.addMethod(
 $core.method({
 selector: "isMetaclass",

+ 4 - 0
lang/src/Kernel-Helpers.st

@@ -26,6 +26,10 @@ isCompiledMethod
 	^ false
 !
 
+isError
+	^ false
+!
+
 isMetaclass
 	^ false
 !

+ 4 - 4
lang/src/Kernel-Infrastructure.js

@@ -2967,11 +2967,11 @@ selector: "asSmalltalkException:",
 protocol: "error handling",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject"],
-source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
-referencedClasses: ["Error", "JavaScriptException"],
+source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ ((self isSmalltalkObject: anObject) and: [ anObject isError ])\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
+referencedClasses: ["JavaScriptException"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["ifTrue:ifFalse:", "and:", "isSmalltalkObject:", "isKindOf:", "on:"]
+messageSends: ["ifTrue:ifFalse:", "and:", "isSmalltalkObject:", "isError", "on:"]
 }, function ($methodClass){ return function (anObject){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -2982,7 +2982,7 @@ $1=$recv($self._isSmalltalkObject_(anObject))._and_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $recv(anObject)._isKindOf_($globals.Error);
+return $recv(anObject)._isError();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");

+ 1 - 1
lang/src/Kernel-Infrastructure.st

@@ -911,7 +911,7 @@ asSmalltalkException: anObject
 	"A JavaScript exception may be thrown.
 	We then need to convert it back to a Smalltalk object"
 	
-	^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])
+	^ ((self isSmalltalkObject: anObject) and: [ anObject isError ])
 		ifTrue: [ anObject ]
 		ifFalse: [ JavaScriptException on: anObject ]
 ! !