Browse Source

'fixture' protocol, commented some base class methods

Herbert Vojčík 11 years ago
parent
commit
e8c346be5d
2 changed files with 65 additions and 55 deletions
  1. 35 35
      js/Kernel-Tests.js
  2. 30 20
      st/Kernel-Tests.st

+ 35 - 35
js/Kernel-Tests.js

@@ -1271,14 +1271,14 @@ smalltalk.CollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collection",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 self._subclassResponsibility();
 return self}, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.CollectionTest)})},
 args: [],
-source: "collection\x0a\x09self subclassResponsibility",
+source: "collection\x0a\x09\x22Answers pre-filled collection of type tested.\x22\x0a\x0a\x09self subclassResponsibility",
 messageSends: ["subclassResponsibility"],
 referencedClasses: []
 }),
@@ -1287,7 +1287,7 @@ smalltalk.CollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -1296,7 +1296,7 @@ $1=_st(self._class())._collectionClass();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest)})},
 args: [],
-source: "collectionClass\x0a\x09^ self class collectionClass",
+source: "collectionClass\x0a\x09\x22Answers class of collection type tested\x22\x0a\x0a\x09^ self class collectionClass",
 messageSends: ["collectionClass", "class"],
 referencedClasses: []
 }),
@@ -1305,14 +1305,14 @@ smalltalk.CollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionWithDuplicates",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 self._subclassResponsibility();
 return self}, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.CollectionTest)})},
 args: [],
-source: "collectionWithDuplicates\x0a\x09self subclassResponsibility",
+source: "collectionWithDuplicates\x0a\x09\x22Answers pre-filled collection of type tested,\x0a\x09with exactly five distinct elements,\x0a\x09some of them appearing multiple times.\x22\x0a\x0a\x09self subclassResponsibility",
 messageSends: ["subclassResponsibility"],
 referencedClasses: []
 }),
@@ -1785,15 +1785,15 @@ smalltalk.CollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-return nil;
-}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest.klass)})},
+self._subclassResponsibility();
+return self}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest.klass)})},
 args: [],
-source: "collectionClass\x0a\x09^ nil",
-messageSends: [],
+source: "collectionClass\x0a\x09\x22Answers class of collection type tested\x22\x0a\x0a\x09self subclassResponsibility",
+messageSends: ["subclassResponsibility"],
 referencedClasses: []
 }),
 smalltalk.CollectionTest.klass);
@@ -1928,7 +1928,7 @@ smalltalk.addClass('HashedCollectionTest', smalltalk.IndexableCollectionTest, []
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collection",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -1952,7 +1952,7 @@ smalltalk.HashedCollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionWithDuplicates",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2109,7 +2109,7 @@ smalltalk.HashedCollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
@@ -2128,7 +2128,7 @@ smalltalk.addClass('DictionaryTest', smalltalk.HashedCollectionTest, [], 'Kernel
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collection",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
@@ -2156,7 +2156,7 @@ smalltalk.DictionaryTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionWithDuplicates",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
@@ -2699,7 +2699,7 @@ smalltalk.DictionaryTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
@@ -2718,7 +2718,7 @@ smalltalk.addClass('SequenceableCollectionTest', smalltalk.IndexableCollectionTe
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirst",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2734,7 +2734,7 @@ smalltalk.SequenceableCollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirstTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2750,7 +2750,7 @@ smalltalk.SequenceableCollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLast",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2766,7 +2766,7 @@ smalltalk.SequenceableCollectionTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLastTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3035,7 +3035,7 @@ smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kerne
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collection",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3053,7 +3053,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirst",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3069,7 +3069,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirstTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3087,7 +3087,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLast",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3103,7 +3103,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLastTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3121,7 +3121,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionWithDuplicates",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3431,7 +3431,7 @@ smalltalk.ArrayTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
@@ -3450,7 +3450,7 @@ smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kern
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collection",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3466,7 +3466,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirst",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3482,7 +3482,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionFirstTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3498,7 +3498,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLast",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3514,7 +3514,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionLastTwo",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -3530,7 +3530,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionWithDuplicates",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -4197,7 +4197,7 @@ smalltalk.StringTest);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "collectionClass",
-protocol: 'accessing',
+protocol: 'fixture',
 fn: function (){
 var self=this;
 function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}

+ 30 - 20
st/Kernel-Tests.st

@@ -382,26 +382,34 @@ TestCase subclass: #CollectionTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!CollectionTest methodsFor: 'accessing'!
+!CollectionTest methodsFor: 'convenience'!
+
+assertSameContents: aCollection as: anotherCollection
+	self assert: (aCollection size = anotherCollection size).
+	aCollection do: [ :each |
+		self assert: ((aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each)) ]
+! !
+
+!CollectionTest methodsFor: 'fixture'!
 
 collection
+	"Answers pre-filled collection of type tested."
+
 	self subclassResponsibility
 !
 
 collectionClass
+	"Answers class of collection type tested"
+
 	^ self class collectionClass
 !
 
 collectionWithDuplicates
-	self subclassResponsibility
-! !
-
-!CollectionTest methodsFor: 'convenience'!
+	"Answers pre-filled collection of type tested,
+	with exactly five distinct elements,
+	some of them appearing multiple times."
 
-assertSameContents: aCollection as: anotherCollection
-	self assert: (aCollection size = anotherCollection size).
-	aCollection do: [ :each |
-		self assert: ((aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each)) ]
+	self subclassResponsibility
 ! !
 
 !CollectionTest methodsFor: 'testing'!
@@ -523,10 +531,12 @@ testSize
 	self assert: self collection size equals: 4
 ! !
 
-!CollectionTest class methodsFor: 'accessing'!
+!CollectionTest class methodsFor: 'fixture'!
 
 collectionClass
-	^ nil
+	"Answers class of collection type tested"
+
+	self subclassResponsibility
 ! !
 
 !CollectionTest class methodsFor: 'testing'!
@@ -568,7 +578,7 @@ IndexableCollectionTest subclass: #HashedCollectionTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!HashedCollectionTest methodsFor: 'accessing'!
+!HashedCollectionTest methodsFor: 'fixture'!
 
 collection
 	^ #{ 'b' -> 1. 'a' -> 2. 'c' -> 3. 'd' -> -4 }
@@ -609,7 +619,7 @@ flattenedAssociations := { 'a'. 1. 'b'. 2 }.
 self assertSameContents: ( self class collectionClass newFromPairs: flattenedAssociations ) as: #{ 'a' -> 1. 'b' -> 2 }.
 ! !
 
-!HashedCollectionTest class methodsFor: 'accessing'!
+!HashedCollectionTest class methodsFor: 'fixture'!
 
 collectionClass
 	^ HashedCollection
@@ -619,7 +629,7 @@ HashedCollectionTest subclass: #DictionaryTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!DictionaryTest methodsFor: 'accessing'!
+!DictionaryTest methodsFor: 'fixture'!
 
 collection
 	^ Dictionary new
@@ -826,7 +836,7 @@ testValues
 	self assert: d values equals: #(2 3 4)
 ! !
 
-!DictionaryTest class methodsFor: 'accessing'!
+!DictionaryTest class methodsFor: 'fixture'!
 
 collectionClass
 	^ Dictionary
@@ -836,7 +846,7 @@ IndexableCollectionTest subclass: #SequenceableCollectionTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!SequenceableCollectionTest methodsFor: 'accessing'!
+!SequenceableCollectionTest methodsFor: 'fixture'!
 
 collectionFirst
 	self subclassResponsibility
@@ -926,7 +936,7 @@ SequenceableCollectionTest subclass: #ArrayTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!ArrayTest methodsFor: 'accessing'!
+!ArrayTest methodsFor: 'fixture'!
 
 collection
 	^ #(1 2 3 -4)
@@ -1041,7 +1051,7 @@ testSort
 	self assert: array equals: #(1 2 3 4 5)
 ! !
 
-!ArrayTest class methodsFor: 'accessing'!
+!ArrayTest class methodsFor: 'fixture'!
 
 collectionClass
 	^ Array
@@ -1051,7 +1061,7 @@ SequenceableCollectionTest subclass: #StringTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!StringTest methodsFor: 'accessing'!
+!StringTest methodsFor: 'fixture'!
 
 collection
 	^ 'hello'
@@ -1258,7 +1268,7 @@ testTrim
 	self assert: 'jackie               ' trimRight equals: 'jackie'.
 ! !
 
-!StringTest class methodsFor: 'accessing'!
+!StringTest class methodsFor: 'fixture'!
 
 collectionClass
 	^ String