Browse Source

Fixes issue #460

Nicolas Petton 11 years ago
parent
commit
2872e6d55e

+ 2 - 1
js/Kernel-Collections.deploy.js

@@ -2438,7 +2438,8 @@ fn: function (aString){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 
-		if(! aString._isString || ! aString._isString()) {
+		if(typeof aString === 'undefined') { return false }
+		if(!aString._isString || ! aString._isString()) {
 			return false;
 		}
 		return String(self) === String(aString)

+ 3 - 2
js/Kernel-Collections.js

@@ -3268,14 +3268,15 @@ fn: function (aString){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 
-		if(! aString._isString || ! aString._isString()) {
+		if(typeof aString === 'undefined') { return false }
+		if(!aString._isString || ! aString._isString()) {
 			return false;
 		}
 		return String(self) === String(aString)
 	;
 return self}, function($ctx1) {$ctx1.fill(self,"=",{aString:aString},smalltalk.String)})},
 args: ["aString"],
-source: "= aString\x0a\x09<\x0a\x09\x09if(! aString._isString || ! aString._isString()) {\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09return String(self) === String(aString)\x0a\x09>",
+source: "= aString\x0a\x09<\x0a\x09\x09if(typeof aString === 'undefined') { return false }\x0a\x09\x09if(!aString._isString || ! aString._isString()) {\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09return String(self) === String(aString)\x0a\x09>",
 messageSends: [],
 referencedClasses: []
 }),

+ 4 - 1
js/Kernel-Tests.deploy.js

@@ -1700,11 +1700,14 @@ var self=this;
 return smalltalk.withContext(function($ctx1) { 
 _st(self)._assert_equals_("hello","hello");
 _st(self)._deny_(_st("hello").__eq("world"));
+_st(self)._deny_(_st("hello").__eq(_st([])._at_ifAbsent_((1),(function(){
+return smalltalk.withContext(function($ctx2) {
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))));
 _st(self)._assert_equals_("hello",_st("hello")._yourself());
 _st(self)._assert_equals_(_st("hello")._yourself(),"hello");
 _st(self)._deny_(_st("").__eq((0)));
 return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.StringTest)})},
-messageSends: ["assert:equals:", "deny:", "=", "yourself"]}),
+messageSends: ["assert:equals:", "deny:", "=", "at:ifAbsent:", "yourself"]}),
 smalltalk.StringTest);
 
 smalltalk.addMethod(

+ 5 - 2
js/Kernel-Tests.js

@@ -2116,13 +2116,16 @@ var self=this;
 return smalltalk.withContext(function($ctx1) { 
 _st(self)._assert_equals_("hello","hello");
 _st(self)._deny_(_st("hello").__eq("world"));
+_st(self)._deny_(_st("hello").__eq(_st([])._at_ifAbsent_((1),(function(){
+return smalltalk.withContext(function($ctx2) {
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))));
 _st(self)._assert_equals_("hello",_st("hello")._yourself());
 _st(self)._assert_equals_(_st("hello")._yourself(),"hello");
 _st(self)._deny_(_st("").__eq((0)));
 return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.StringTest)})},
 args: [],
-source: "testEquality\x0a\x09self assert: 'hello' equals: 'hello'.\x0a\x09self deny: 'hello' = 'world'.\x0a\x0a\x09self assert: 'hello' equals: 'hello' yourself.\x0a\x09self assert: 'hello' yourself equals: 'hello'.\x0a\x0a\x09\x22test JS falsy value\x22\x0a\x09self deny: '' = 0",
-messageSends: ["assert:equals:", "deny:", "=", "yourself"],
+source: "testEquality\x0a\x09self assert: 'hello' equals: 'hello'.\x0a\x09self deny: 'hello' = 'world'.\x0a\x09\x0a\x09\x22Test for issue 459\x22\x0a\x09self deny: 'hello' = (#() at: 1 ifAbsent: [ ]).\x0a\x0a\x09self assert: 'hello' equals: 'hello' yourself.\x0a\x09self assert: 'hello' yourself equals: 'hello'.\x0a\x0a\x09\x22test JS falsy value\x22\x0a\x09self deny: '' = 0",
+messageSends: ["assert:equals:", "deny:", "=", "at:ifAbsent:", "yourself"],
 referencedClasses: []
 }),
 smalltalk.StringTest);

+ 2 - 1
st/Kernel-Collections.st

@@ -1133,7 +1133,8 @@ unescaped
 
 = aString
 	<
-		if(!! aString._isString || !! aString._isString()) {
+		if(typeof aString === 'undefined') { return false }
+		if(!!aString._isString || !! aString._isString()) {
 			return false;
 		}
 		return String(self) === String(aString)

+ 3 - 0
st/Kernel-Tests.st

@@ -808,6 +808,9 @@ testDetect
 testEquality
 	self assert: 'hello' equals: 'hello'.
 	self deny: 'hello' = 'world'.
+	
+	"Test for issue 459"
+	self deny: 'hello' = (#() at: 1 ifAbsent: [ ]).
 
 	self assert: 'hello' equals: 'hello' yourself.
 	self assert: 'hello' yourself equals: 'hello'.