Permalink
Browse files

Fix NonBooleanReceiver error not sent when invoking a Boolean method …

…on a non-boolean javascript value
  • Loading branch information...
1 parent e2a30be commit ceb675685ac71317b105dde75612013c611f8e1a @lolgzs lolgzs committed Nov 12, 2012
Showing with 48 additions and 1 deletion.
  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
View
@@ -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');
View
@@ -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');
View
@@ -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();
View
@@ -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

0 comments on commit ceb6756

Please sign in to comment.