Selaa lähdekoodia

Merge branch 'allow-comma-for-hashedcollection' of https://github.com/herby/amber into herby-allow-comma-for-hashedcollection

Conflicts:
	API-CHANGES.txt
Nicolas Petton 10 vuotta sitten
vanhempi
commit
49ccac8777
5 muutettua tiedostoa jossa 35 lisäystä ja 32 poistoa
  1. 2 0
      API-CHANGES.txt
  2. 0 16
      js/Kernel-Collections.js
  3. 29 11
      js/Kernel-Tests.js
  4. 0 4
      st/Kernel-Collections.st
  5. 4 1
      st/Kernel-Tests.st

+ 2 - 0
API-CHANGES.txt

@@ -2,7 +2,9 @@
 
 * Package Import-Export renamed to Kernel-ImportExport
 * A dozen of methods moved from Object to ProtoObject
+
 * HashedCollection >> at:ifAbsentPut: pushed up to SequenceableCollection
+* HashedCollection >> , is now allowed (removed shouldNotImplement)
 
 + CompiledMethod >>
   + defaultProtocol

+ 0 - 16
js/Kernel-Collections.js

@@ -1303,22 +1303,6 @@ smalltalk.IndexableCollection);
 
 smalltalk.addClass('HashedCollection', smalltalk.IndexableCollection, [], 'Kernel-Collections');
 smalltalk.HashedCollection.comment="I am a traditional JavaScript object, or a Smalltalk `Dictionary`.\x0a\x0aUnlike a `Dictionary`, I can only have strings as keys.";
-smalltalk.addMethod(
-smalltalk.method({
-selector: ",",
-protocol: 'copying',
-fn: function (aCollection){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._shouldNotImplement();
-return self}, function($ctx1) {$ctx1.fill(self,",",{aCollection:aCollection},smalltalk.HashedCollection)})},
-args: ["aCollection"],
-source: ", aCollection\x0a\x09self shouldNotImplement",
-messageSends: ["shouldNotImplement"],
-referencedClasses: []
-}),
-smalltalk.HashedCollection);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "=",

+ 29 - 11
js/Kernel-Tests.js

@@ -2901,20 +2901,38 @@ selector: "testComma",
 protocol: 'tests',
 fn: function (){
 var self=this;
-function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
-var $1;
-self._should_raise_((function(){
-return smalltalk.withContext(function($ctx2) {
-$1=self._collection();
-$ctx2.sendIdx["collection"]=1;
-return _st($1).__comma(self._collection());
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
+var $2,$3,$1,$4,$6,$7,$5,$8,$10,$9;
+smalltalk.HashedCollectionTest.superclass.fn.prototype._testComma.apply(_st(self), []);
+$2=self._collection();
+$ctx1.sendIdx["collection"]=1;
+$3=self._collection();
+$ctx1.sendIdx["collection"]=2;
+$1=_st($2).__comma($3);
+$ctx1.sendIdx[","]=1;
+$4=self._collection();
+$ctx1.sendIdx["collection"]=3;
+self._assert_equals_($1,$4);
+$ctx1.sendIdx["assert:equals:"]=1;
+$6=self._collection();
+$ctx1.sendIdx["collection"]=4;
+$7=self._collectionWithNewValue();
+$ctx1.sendIdx["collectionWithNewValue"]=1;
+$5=_st($6).__comma($7);
+$ctx1.sendIdx[","]=2;
+$8=self._collectionWithNewValue();
+$ctx1.sendIdx["collectionWithNewValue"]=2;
+self._assert_equals_($5,$8);
+$ctx1.sendIdx["assert:equals:"]=2;
+$10=self._collectionWithNewValue();
+$ctx1.sendIdx["collectionWithNewValue"]=3;
+$9=_st($10).__comma(self._collection());
+self._assert_equals_($9,self._collectionWithNewValue());
 return self}, function($ctx1) {$ctx1.fill(self,"testComma",{},smalltalk.HashedCollectionTest)})},
 args: [],
-source: "testComma\x0a\x09self should: [ self collection, self collection ] raise: Error",
-messageSends: ["should:raise:", ",", "collection"],
-referencedClasses: ["Error"]
+source: "testComma\x0a\x09super testComma.\x0a\x09self assert: self collection, self collection equals: self collection.\x0a\x09self assert: self collection, self collectionWithNewValue equals: self collectionWithNewValue.\x0a\x09self assert: self collectionWithNewValue, self collection equals: self collectionWithNewValue",
+messageSends: ["testComma", "assert:equals:", ",", "collection", "collectionWithNewValue"],
+referencedClasses: []
 }),
 smalltalk.HashedCollectionTest);
 

+ 0 - 4
st/Kernel-Collections.st

@@ -553,10 +553,6 @@ asJSON
 
 !HashedCollection methodsFor: 'copying'!
 
-, aCollection
-	self shouldNotImplement
-!
-
 deepCopy
 	| copy |
 	copy := self class new.

+ 4 - 1
st/Kernel-Tests.st

@@ -790,7 +790,10 @@ self assert: ( self collectionClass new asDictionary isMemberOf: Dictionary ).
 !
 
 testComma
-	self should: [ self collection, self collection ] raise: Error
+	super testComma.
+	self assert: self collection, self collection equals: self collection.
+	self assert: self collection, self collectionWithNewValue equals: self collectionWithNewValue.
+	self assert: self collectionWithNewValue, self collection equals: self collectionWithNewValue
 !
 
 testFrom