Explorar el Código

Merge pull request #247 from lolgzs/fix-NonBooleanReceiver

Fix NonBooleanReceiver error not sent when invoking a Boolean method on ...
Nicolas Petton hace 12 años
padre
commit
00efb54ece
Se han modificado 4 ficheros con 48 adiciones y 1 borrados
  1. 18 0
      js/Kernel-Tests.deploy.js
  2. 23 0
      js/Kernel-Tests.js
  3. 1 1
      js/boot.js
  4. 6 0
      st/Kernel-Tests.st

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

@@ -322,6 +322,24 @@ return self}
 }),
 smalltalk.BooleanTest);
 
+smalltalk.addMethod(
+"_testNonBooleanError",
+smalltalk.method({
+selector: "testNonBooleanError",
+fn: function (){
+var self=this;
+var b;
+b= '' ;
+;
+smalltalk.send(self,"_should_raise_",[(function(){
+if(smalltalk.assert(self["@nonBoolean"])){
+} else {
+};
+}),(smalltalk.NonBooleanReceiver || NonBooleanReceiver)]);
+return self}
+}),
+smalltalk.BooleanTest);
+
 
 
 smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');

+ 23 - 0
js/Kernel-Tests.js

@@ -387,6 +387,29 @@ referencedClasses: []
 }),
 smalltalk.BooleanTest);
 
+smalltalk.addMethod(
+"_testNonBooleanError",
+smalltalk.method({
+selector: "testNonBooleanError",
+category: 'tests',
+fn: function (){
+var self=this;
+var b;
+b= '' ;
+;
+smalltalk.send(self,"_should_raise_",[(function(){
+if(smalltalk.assert(self["@nonBoolean"])){
+} else {
+};
+}),(smalltalk.NonBooleanReceiver || NonBooleanReceiver)]);
+return self},
+args: [],
+source: "testNonBooleanError\x0a\x09|b|\x0a    b := < '' >.\x0a    self should: [nonBoolean ifTrue: [] ifFalse: []] raise: NonBooleanReceiver",
+messageSends: ["should:raise:", "ifTrue:ifFalse:"],
+referencedClasses: ["NonBooleanReceiver"]
+}),
+smalltalk.BooleanTest);
+
 
 
 smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');

+ 1 - 1
js/boot.js

@@ -567,7 +567,7 @@ function Smalltalk(){
 
     /* Boolean assertion */
     st.assert = function(boolean) {
-        if(boolean.klass === smalltalk.Boolean) {
+        if ((undefined !== boolean) && (boolean.klass === smalltalk.Boolean)) {
             return boolean;
         } else {
             smalltalk.NonBooleanReceiver._new()._object_(boolean)._signal();

+ 6 - 0
st/Kernel-Tests.st

@@ -150,6 +150,12 @@ testLogicKeywords
 		assert: (false or: [ 1 > 0 ]); 
 		assert: ((1 > 0) or: [ false ]); 
 		assert: ((1 > 0) or: [ 1 > 2 ])
+!
+
+testNonBooleanError
+	|b|
+    b := < '' >.
+    self should: [nonBoolean ifTrue: [] ifFalse: []] raise: NonBooleanReceiver
 ! !
 
 TestCase subclass: #ClassBuilderTest