Browse Source

Pushing collection{,WithDuplicates} down from base class

Herbert Vojčík 11 years ago
parent
commit
d38bf9a76b
2 changed files with 56 additions and 36 deletions
  1. 44 30
      js/Kernel-Tests.js
  2. 12 6
      st/Kernel-Tests.st

+ 44 - 30
js/Kernel-Tests.js

@@ -1275,13 +1275,11 @@ protocol: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._collectionClass())._withAll_(self._defaultValues());
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.CollectionTest)})},
+self._subclassResponsibility();
+return self}, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.CollectionTest)})},
 args: [],
-source: "collection\x0a\x09^ self collectionClass withAll: self defaultValues",
-messageSends: ["withAll:", "collectionClass", "defaultValues"],
+source: "collection\x0a\x09self subclassResponsibility",
+messageSends: ["subclassResponsibility"],
 referencedClasses: []
 }),
 smalltalk.CollectionTest);
@@ -1311,31 +1309,11 @@ protocol: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._collectionClass())._withAll_(["a", "b", "c", (1), (2), (1), "a"]);
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.CollectionTest)})},
+self._subclassResponsibility();
+return self}, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.CollectionTest)})},
 args: [],
-source: "collectionWithDuplicates\x0a\x09^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')",
-messageSends: ["withAll:", "collectionClass"],
-referencedClasses: []
-}),
-smalltalk.CollectionTest);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "defaultValues",
-protocol: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=[(1), (2), (3), (-4)];
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"defaultValues",{},smalltalk.CollectionTest)})},
-args: [],
-source: "defaultValues\x0a\x09^ #(1 2 3 -4)",
-messageSends: [],
+source: "collectionWithDuplicates\x0a\x09self subclassResponsibility",
+messageSends: ["subclassResponsibility"],
 referencedClasses: []
 }),
 smalltalk.CollectionTest);
@@ -2974,6 +2952,42 @@ smalltalk.SequenceableCollectionTest);
 
 
 smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "collection",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=[(1), (2), (3), (-4)];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.ArrayTest)})},
+args: [],
+source: "collection\x0a\x09^#(1 2 3 -4)",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.ArrayTest);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "collectionWithDuplicates",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=["a", "b", "c", (1), (2), (1), "a"];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.ArrayTest)})},
+args: [],
+source: "collectionWithDuplicates\x0a\x09^#('a' 'b' 'c' 1 2 1 'a')",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.ArrayTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testAdd",

+ 12 - 6
st/Kernel-Tests.st

@@ -385,7 +385,7 @@ TestCase subclass: #CollectionTest
 !CollectionTest methodsFor: 'accessing'!
 
 collection
-	^ self collectionClass withAll: self defaultValues
+	self subclassResponsibility
 !
 
 collectionClass
@@ -393,11 +393,7 @@ collectionClass
 !
 
 collectionWithDuplicates
-	^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')
-!
-
-defaultValues
-	^ #(1 2 3 -4)
+	self subclassResponsibility
 ! !
 
 !CollectionTest methodsFor: 'convenience'!
@@ -892,6 +888,16 @@ SequenceableCollectionTest subclass: #ArrayTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
+!ArrayTest methodsFor: 'accessing'!
+
+collection
+	^#(1 2 3 -4)
+!
+
+collectionWithDuplicates
+	^#('a' 'b' 'c' 1 2 1 'a')
+! !
+
 !ArrayTest methodsFor: 'tests'!
 
 testAdd