Sfoglia il codice sorgente

Collection tests refactorings and improvements

Nicolas Petton 11 anni fa
parent
commit
c873f3c620
3 ha cambiato i file con 785 aggiunte e 83 eliminazioni
  1. 280 29
      js/Kernel-Tests.deploy.js
  2. 386 40
      js/Kernel-Tests.js
  3. 119 14
      st/Kernel-Tests.st

+ 280 - 29
js/Kernel-Tests.deploy.js

@@ -858,7 +858,69 @@ messageSends: ["isNil", "collectionClass"]}),
 smalltalk.CollectionTest.klass);
 
 
-smalltalk.addClass('HashedCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
+smalltalk.addClass('IndexableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_testAt",
+smalltalk.method({
+selector: "testAt",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_((4)),(-4));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.IndexableCollectionTest)})},
+messageSends: ["assert:equals:", "at:", "collection", "should:raise:"]}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testAtIfAbsent",
+smalltalk.method({
+selector: "testAtIfAbsent",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
+return smalltalk.withContext(function($ctx2) {
return "none";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"none");
+return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.IndexableCollectionTest)})},
+messageSends: ["assert:equals:", "at:ifAbsent:", "+", "size", "collection"]}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_((2)),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.IndexableCollectionTest)})},
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"]}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testWithIndexDo",
+smalltalk.method({
+selector: "testWithIndexDo",
+fn: function (){
+var self=this;
+var collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._collection();
+_st(_st(self)._collection())._withIndexDo_((function(each,index){
+return smalltalk.withContext(function($ctx2) {
return _st(self)._assert_equals_(_st(collection)._at_(index),each);
+}, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"testWithIndexDo",{collection:collection},smalltalk.IndexableCollectionTest)})},
+messageSends: ["collection", "withIndexDo:", "assert:equals:", "at:"]}),
+smalltalk.IndexableCollectionTest);
+
+
+
+smalltalk.addClass('HashedCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_collection",
 smalltalk.method({
@@ -885,6 +947,20 @@ return $1;
 messageSends: ["->"]}),
 smalltalk.HashedCollectionTest);
 
+smalltalk.addMethod(
+"_testAt",
+smalltalk.method({
+selector: "testAt",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_("a"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.HashedCollectionTest)})},
+messageSends: ["assert:equals:", "at:", "collection", "should:raise:"]}),
+smalltalk.HashedCollectionTest);
+
 smalltalk.addMethod(
 "_testIndexOf",
 smalltalk.method({
@@ -1255,34 +1331,7 @@ messageSends: []}),
 smalltalk.DictionaryTest.klass);
 
 
-smalltalk.addClass('SequenceableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
-smalltalk.addMethod(
-"_testAt",
-smalltalk.method({
-selector: "testAt",
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_((4)),(-4));
-_st(self)._should_raise_((function(){
-return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
-return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.SequenceableCollectionTest)})},
-messageSends: ["assert:equals:", "at:", "collection", "should:raise:"]}),
-smalltalk.SequenceableCollectionTest);
-
-smalltalk.addMethod(
-"_testAtIfAbsent",
-smalltalk.method({
-selector: "testAtIfAbsent",
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
-return smalltalk.withContext(function($ctx2) {
return "none";
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"none");
-return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.SequenceableCollectionTest)})},
-messageSends: ["assert:equals:", "at:ifAbsent:", "+", "size", "collection"]}),
-smalltalk.SequenceableCollectionTest);
-
+smalltalk.addClass('SequenceableCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
 
 
 smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
@@ -1543,6 +1592,23 @@ return self}, function($ctx1) {$ctx1.fill(self,"testIncludesSubString",{},smallt
 messageSends: ["assert:", "includesSubString:", "deny:"]}),
 smalltalk.StringTest);
 
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_("e"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.StringTest)})},
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"]}),
+smalltalk.StringTest);
+
 smalltalk.addMethod(
 "_testJoin",
 smalltalk.method({
@@ -1780,6 +1846,23 @@ return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.Symbo
 messageSends: ["assert:", "==", "deny:", "=", "yourself", "asSymbol", "asString"]}),
 smalltalk.SymbolTest);
 
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_("e"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.SymbolTest)})},
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"]}),
+smalltalk.SymbolTest);
+
 smalltalk.addMethod(
 "_testIsEmpty",
 smalltalk.method({
@@ -3085,6 +3168,174 @@ smalltalk.SetTest);
 
 
 
+smalltalk.addClass('StreamTest', smalltalk.TestCase, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._class())._collectionClass();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest)})},
+messageSends: ["collectionClass", "class"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._collectionClass())._new();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StreamTest)})},
+messageSends: ["new", "collectionClass"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_newStream",
+smalltalk.method({
+selector: "newStream",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(_st(self)._collectionClass())._new())._stream();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.StreamTest)})},
+messageSends: ["stream", "new", "collectionClass"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testAtEnd",
+smalltalk.method({
+selector: "testAtEnd",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.StreamTest)})},
+messageSends: []}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testAtStart",
+smalltalk.method({
+selector: "testAtStart",
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testAtStart",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testContents",
+smalltalk.method({
+selector: "testContents",
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testPosition",
+smalltalk.method({
+selector: "testPosition",
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testReading",
+smalltalk.method({
+selector: "testReading",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testReading",{},smalltalk.StreamTest)})},
+messageSends: []}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testStreamContents",
+smalltalk.method({
+selector: "testStreamContents",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StreamTest)})},
+messageSends: []}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testWrite",
+smalltalk.method({
+selector: "testWrite",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{},smalltalk.StreamTest)})},
+messageSends: []}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testWriting",
+smalltalk.method({
+selector: "testWriting",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{},smalltalk.StreamTest)})},
+messageSends: []}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testisEmpty",
+smalltalk.method({
+selector: "testisEmpty",
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testisEmpty",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+smalltalk.StreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return nil;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest.klass)})},
+messageSends: []}),
+smalltalk.StreamTest.klass);
+
+smalltalk.addMethod(
+"_isAbstract",
+smalltalk.method({
+selector: "isAbstract",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._collectionClass())._isNil();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.StreamTest.klass)})},
+messageSends: ["isNil", "collectionClass"]}),
+smalltalk.StreamTest.klass);
+
+
 smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_testCopying",

+ 386 - 40
js/Kernel-Tests.js

@@ -1078,7 +1078,89 @@ referencedClasses: []
 smalltalk.CollectionTest.klass);
 
 
-smalltalk.addClass('HashedCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
+smalltalk.addClass('IndexableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_testAt",
+smalltalk.method({
+selector: "testAt",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_((4)),(-4));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.IndexableCollectionTest)})},
+args: [],
+source: "testAt\x0a\x09self assert: (self collection at: 4) equals: -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
+messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testAtIfAbsent",
+smalltalk.method({
+selector: "testAtIfAbsent",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
+return smalltalk.withContext(function($ctx2) {
return "none";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"none");
+return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.IndexableCollectionTest)})},
+args: [],
+source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'",
+messageSends: ["assert:equals:", "at:ifAbsent:", "+", "size", "collection"],
+referencedClasses: []
+}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_((2)),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.IndexableCollectionTest)})},
+args: [],
+source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 2) equals: 2.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.IndexableCollectionTest);
+
+smalltalk.addMethod(
+"_testWithIndexDo",
+smalltalk.method({
+selector: "testWithIndexDo",
+category: 'tests',
+fn: function (){
+var self=this;
+var collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._collection();
+_st(_st(self)._collection())._withIndexDo_((function(each,index){
+return smalltalk.withContext(function($ctx2) {
return _st(self)._assert_equals_(_st(collection)._at_(index),each);
+}, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"testWithIndexDo",{collection:collection},smalltalk.IndexableCollectionTest)})},
+args: [],
+source: "testWithIndexDo\x0a\x09| collection |\x0a\x09collection := self collection.\x0a\x09\x0a\x09self collection withIndexDo: [ :each :index |\x0a\x09\x09self assert: (collection at: index) equals: each ]",
+messageSends: ["collection", "withIndexDo:", "assert:equals:", "at:"],
+referencedClasses: []
+}),
+smalltalk.IndexableCollectionTest);
+
+
+
+smalltalk.addClass('HashedCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_collection",
 smalltalk.method({
@@ -1115,6 +1197,25 @@ referencedClasses: []
 }),
 smalltalk.HashedCollectionTest);
 
+smalltalk.addMethod(
+"_testAt",
+smalltalk.method({
+selector: "testAt",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_("a"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.HashedCollectionTest)})},
+args: [],
+source: "testAt\x0a\x09self assert: (self collection at: 'a') equals: 2.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
+messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.HashedCollectionTest);
+
 smalltalk.addMethod(
 "_testIndexOf",
 smalltalk.method({
@@ -1131,7 +1232,7 @@ return smalltalk.withContext(function($ctx2) {
return "sentinel";
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
 return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.HashedCollectionTest)})},
 args: [],
-source: "testIndexOf\x0a\x0a\x09self assert: (self collection indexOf: 2) equals: 'a'.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
+source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 2) equals: 'a'.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
 messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
 referencedClasses: ["Error"]
 }),
@@ -1575,44 +1676,7 @@ referencedClasses: ["Dictionary"]
 smalltalk.DictionaryTest.klass);
 
 
-smalltalk.addClass('SequenceableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
-smalltalk.addMethod(
-"_testAt",
-smalltalk.method({
-selector: "testAt",
-category: 'tests',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_((4)),(-4));
-_st(self)._should_raise_((function(){
-return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._at_((5));
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
-return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.SequenceableCollectionTest)})},
-args: [],
-source: "testAt\x0a\x09self assert: (self collection at: 4) equals: -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
-messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
-referencedClasses: ["Error"]
-}),
-smalltalk.SequenceableCollectionTest);
-
-smalltalk.addMethod(
-"_testAtIfAbsent",
-smalltalk.method({
-selector: "testAtIfAbsent",
-category: 'tests',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
-return smalltalk.withContext(function($ctx2) {
return "none";
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"none");
-return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.SequenceableCollectionTest)})},
-args: [],
-source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'",
-messageSends: ["assert:equals:", "at:ifAbsent:", "+", "size", "collection"],
-referencedClasses: []
-}),
-smalltalk.SequenceableCollectionTest);
-
+smalltalk.addClass('SequenceableCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
 
 
 smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
@@ -1958,6 +2022,28 @@ referencedClasses: []
 }),
 smalltalk.StringTest);
 
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_("e"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.StringTest)})},
+args: [],
+source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 'e') equals: 2.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.StringTest);
+
 smalltalk.addMethod(
 "_testJoin",
 smalltalk.method({
@@ -2280,6 +2366,28 @@ referencedClasses: []
 }),
 smalltalk.SymbolTest);
 
+smalltalk.addMethod(
+"_testIndexOf",
+smalltalk.method({
+selector: "testIndexOf",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_("e"),(2));
+_st(self)._should_raise_((function(){
+return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._collection())._indexOf_((999));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
+_st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
+return smalltalk.withContext(function($ctx2) {
return "sentinel";
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
+return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.SymbolTest)})},
+args: [],
+source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 'e') equals: 2.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
+messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
+referencedClasses: ["Error"]
+}),
+smalltalk.SymbolTest);
+
 smalltalk.addMethod(
 "_testIsEmpty",
 smalltalk.method({
@@ -3971,6 +4079,244 @@ smalltalk.SetTest);
 
 
 
+smalltalk.addClass('StreamTest', smalltalk.TestCase, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._class())._collectionClass();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest)})},
+args: [],
+source: "collectionClass\x0a\x09^ self class collectionClass",
+messageSends: ["collectionClass", "class"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._collectionClass())._new();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StreamTest)})},
+args: [],
+source: "newCollection\x0a\x09^ self collectionClass new",
+messageSends: ["new", "collectionClass"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_newStream",
+smalltalk.method({
+selector: "newStream",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(_st(self)._collectionClass())._new())._stream();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.StreamTest)})},
+args: [],
+source: "newStream\x0a\x09^ self collectionClass new stream",
+messageSends: ["stream", "new", "collectionClass"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testAtEnd",
+smalltalk.method({
+selector: "testAtEnd",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.StreamTest)})},
+args: [],
+source: "testAtEnd",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testAtStart",
+smalltalk.method({
+selector: "testAtStart",
+category: 'tests',
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testAtStart",{stream:stream},smalltalk.StreamTest)})},
+args: [],
+source: "testAtStart\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
+messageSends: ["newStream", "nextPutAll:", "newCollection"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testContents",
+smalltalk.method({
+selector: "testContents",
+category: 'tests',
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
+args: [],
+source: "testContents\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
+messageSends: ["newStream", "nextPutAll:", "newCollection"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testPosition",
+smalltalk.method({
+selector: "testPosition",
+category: 'tests',
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{stream:stream},smalltalk.StreamTest)})},
+args: [],
+source: "testPosition\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
+messageSends: ["newStream", "nextPutAll:", "newCollection"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testReading",
+smalltalk.method({
+selector: "testReading",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testReading",{},smalltalk.StreamTest)})},
+args: [],
+source: "testReading",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testStreamContents",
+smalltalk.method({
+selector: "testStreamContents",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StreamTest)})},
+args: [],
+source: "testStreamContents",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testWrite",
+smalltalk.method({
+selector: "testWrite",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{},smalltalk.StreamTest)})},
+args: [],
+source: "testWrite",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testWriting",
+smalltalk.method({
+selector: "testWriting",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{},smalltalk.StreamTest)})},
+args: [],
+source: "testWriting",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+smalltalk.addMethod(
+"_testisEmpty",
+smalltalk.method({
+selector: "testisEmpty",
+category: 'tests',
+fn: function (){
+var self=this;
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testisEmpty",{stream:stream},smalltalk.StreamTest)})},
+args: [],
+source: "testisEmpty\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
+messageSends: ["newStream", "nextPutAll:", "newCollection"],
+referencedClasses: []
+}),
+smalltalk.StreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return nil;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest.klass)})},
+args: [],
+source: "collectionClass\x0a\x09^ nil",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StreamTest.klass);
+
+smalltalk.addMethod(
+"_isAbstract",
+smalltalk.method({
+selector: "isAbstract",
+category: 'testing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st(self)._collectionClass())._isNil();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.StreamTest.klass)})},
+args: [],
+source: "isAbstract\x0a\x09^ self collectionClass isNil",
+messageSends: ["isNil", "collectionClass"],
+referencedClasses: []
+}),
+smalltalk.StreamTest.klass);
+
+
 smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_testCopying",

+ 119 - 14
st/Kernel-Tests.st

@@ -421,7 +421,36 @@ isAbstract
 	^ self collectionClass isNil
 ! !
 
-CollectionTest subclass: #HashedCollectionTest
+CollectionTest subclass: #IndexableCollectionTest
+	instanceVariableNames: ''
+	package: 'Kernel-Tests'!
+
+!IndexableCollectionTest methodsFor: 'tests'!
+
+testAt
+	self assert: (self collection at: 4) equals: -4.
+	self should: [ self collection at: 5 ] raise: Error
+!
+
+testAtIfAbsent
+	self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'
+!
+
+testIndexOf
+	self assert: (self collection indexOf: 2) equals: 2.
+	self should: [ self collection indexOf: 999 ] raise: Error.
+	self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'
+!
+
+testWithIndexDo
+	| collection |
+	collection := self collection.
+	
+	self collection withIndexDo: [ :each :index |
+		self assert: (collection at: index) equals: each ]
+! !
+
+IndexableCollectionTest subclass: #HashedCollectionTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
@@ -437,8 +466,12 @@ collectionWithDuplicates
 
 !HashedCollectionTest methodsFor: 'tests'!
 
-testIndexOf
+testAt
+	self assert: (self collection at: 'a') equals: 2.
+	self should: [ self collection at: 5 ] raise: Error
+!
 
+testIndexOf
 	self assert: (self collection indexOf: 2) equals: 'a'.
 	self should: [ self collection indexOf: 999 ] raise: Error.
 	self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'
@@ -663,21 +696,10 @@ collectionClass
 	^ Dictionary
 ! !
 
-CollectionTest subclass: #SequenceableCollectionTest
+IndexableCollectionTest subclass: #SequenceableCollectionTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
 
-!SequenceableCollectionTest methodsFor: 'tests'!
-
-testAt
-	self assert: (self collection at: 4) equals: -4.
-	self should: [ self collection at: 5 ] raise: Error
-!
-
-testAtIfAbsent
-	self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'
-! !
-
 SequenceableCollectionTest subclass: #ArrayTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!
@@ -810,6 +832,12 @@ testIncludesSubString
 	self deny: ('amber' includesSubString: 'zork').
 !
 
+testIndexOf
+	self assert: (self collection indexOf: 'e') equals: 2.
+	self should: [ self collection indexOf: 999 ] raise: Error.
+	self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'
+!
+
 testJoin
 	self assert: (',' join: #('hello' 'world')) equals: 'hello,world'
 !
@@ -932,6 +960,12 @@ testIdentity
 	self assert: #hello yourself = #hello asString asSymbol
 !
 
+testIndexOf
+	self assert: (self collection indexOf: 'e') equals: 2.
+	self should: [ self collection indexOf: 999 ] raise: Error.
+	self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'
+!
+
 testIsEmpty
 	self deny: self collection isEmpty.
 	self assert: '' asSymbol isEmpty
@@ -1602,6 +1636,77 @@ testUnicity
 	self assert: set asArray equals: #(21 'hello')
 ! !
 
+TestCase subclass: #StreamTest
+	instanceVariableNames: ''
+	package: 'Kernel-Tests'!
+
+!StreamTest methodsFor: 'accessing'!
+
+collectionClass
+	^ self class collectionClass
+!
+
+newCollection
+	^ self collectionClass new
+!
+
+newStream
+	^ self collectionClass new stream
+! !
+
+!StreamTest methodsFor: 'tests'!
+
+testAtEnd
+!
+
+testAtStart
+	| stream |
+	stream := self newStream.
+	stream nextPutAll: self newCollection.
+!
+
+testContents
+	| stream |
+	stream := self newStream.
+	stream nextPutAll: self newCollection.
+!
+
+testPosition
+	| stream |
+	stream := self newStream.
+	stream nextPutAll: self newCollection.
+!
+
+testReading
+!
+
+testStreamContents
+!
+
+testWrite
+!
+
+testWriting
+!
+
+testisEmpty
+	| stream |
+	stream := self newStream.
+	stream nextPutAll: self newCollection.
+! !
+
+!StreamTest class methodsFor: 'accessing'!
+
+collectionClass
+	^ nil
+! !
+
+!StreamTest class methodsFor: 'testing'!
+
+isAbstract
+	^ self collectionClass isNil
+! !
+
 TestCase subclass: #UndefinedTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!