Browse Source

Merge pull request #766 from herby/gh-763

Fixes #763 - invalid at:put:s return value put, plus test
Nicolas Petton 11 years ago
parent
commit
b875c2fd75
6 changed files with 40 additions and 6 deletions
  1. 2 2
      js/Canvas.js
  2. 2 2
      js/Kernel-Infrastructure.js
  3. 25 0
      js/Kernel-Tests.js
  4. 1 1
      st/Canvas.st
  5. 1 1
      st/Kernel-Infrastructure.st
  6. 9 0
      st/Kernel-Tests.st

+ 2 - 2
js/Canvas.js

@@ -2704,10 +2704,10 @@ category: 'attributes',
 fn: function (aString,aValue){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self['@element'].setAttribute(aString, aValue);
+self['@element'].setAttribute(aString, aValue); return aValue;
 return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,aValue:aValue},smalltalk.TagBrush)})},
 args: ["aString", "aValue"],
-source: "at: aString put: aValue\x0a\x09<self['@element'].setAttribute(aString, aValue)>",
+source: "at: aString put: aValue\x0a\x09<self['@element'].setAttribute(aString, aValue); return aValue>",
 messageSends: [],
 referencedClasses: []
 }),

+ 2 - 2
js/Kernel-Infrastructure.js

@@ -415,10 +415,10 @@ category: 'accessing',
 fn: function (aString,anObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self['@jsObject'][aString] = anObject;
+return self['@jsObject'][aString] = anObject;
 return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},smalltalk.JSObjectProxy)})},
 args: ["aString", "anObject"],
-source: "at: aString put: anObject\x0a\x09<self['@jsObject'][aString] = anObject>",
+source: "at: aString put: anObject\x0a\x09<return self['@jsObject'][aString] = anObject>",
 messageSends: [],
 referencedClasses: []
 }),

+ 25 - 0
js/Kernel-Tests.js

@@ -4083,6 +4083,31 @@ referencedClasses: []
 }),
 smalltalk.JSObjectProxyTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testAtPut",
+category: 'tests',
+fn: function (){
+var self=this;
+var testObject;
+return smalltalk.withContext(function($ctx1) { 
+var $2,$1;
+testObject=self._jsObject();
+$2=_st(testObject)._at_("abc");
+$ctx1.sendIdx["at:"]=1;
+$1=_st($2).__tild_eq("xyz");
+self._assert_($1);
+self._assert_equals_(_st(testObject)._at_put_("abc","xyz"),"xyz");
+$ctx1.sendIdx["assert:equals:"]=1;
+self._assert_equals_(_st(testObject)._at_("abc"),"xyz");
+return self}, function($ctx1) {$ctx1.fill(self,"testAtPut",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
+args: [],
+source: "testAtPut\x0a\x09| testObject |\x0a\x09testObject := self jsObject.\x0a\x09\x0a\x09self assert: (testObject at: 'abc') ~= 'xyz'.\x0a\x09self assert: (testObject at: 'abc' put: 'xyz') equals: 'xyz'.\x0a\x09self assert: (testObject at: 'abc') equals: 'xyz'",
+messageSends: ["jsObject", "assert:", "~=", "at:", "assert:equals:", "at:put:"],
+referencedClasses: []
+}),
+smalltalk.JSObjectProxyTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testDNU",

+ 1 - 1
st/Canvas.st

@@ -807,7 +807,7 @@ at: aString ifAbsent: aBlock
 !
 
 at: aString put: aValue
-	<self['@element'].setAttribute(aString, aValue)>
+	<self['@element'].setAttribute(aString, aValue); return aValue>
 !
 
 class: aString

+ 1 - 1
st/Kernel-Infrastructure.st

@@ -157,7 +157,7 @@ at: aString ifPresent: aBlock ifAbsent: anotherBlock
 !
 
 at: aString put: anObject
-	<self['@jsObject'][aString] = anObject>
+	<return self['@jsObject'][aString] = anObject>
 !
 
 jsObject

+ 9 - 0
st/Kernel-Tests.st

@@ -1224,6 +1224,15 @@ testAtIfPresentIfAbsent
 	self assert: (testObject at: 'f' ifPresent: [ :x|'hello ',x asString ] ifAbsent: [ 'not present' ]) equals: 'hello nil'.
 !
 
+testAtPut
+	| testObject |
+	testObject := self jsObject.
+	
+	self assert: (testObject at: 'abc') ~= 'xyz'.
+	self assert: (testObject at: 'abc' put: 'xyz') equals: 'xyz'.
+	self assert: (testObject at: 'abc') equals: 'xyz'
+!
+
 testDNU
 	self should: [ self jsObject foo ] raise: MessageNotUnderstood
 !