浏览代码

Stream improvements and tests

Nicolas Petton 11 年之前
父节点
当前提交
43f674df33
共有 6 个文件被更改,包括 453 次插入102 次删除
  1. 24 2
      js/Kernel-Collections.deploy.js
  2. 35 3
      js/Kernel-Collections.js
  3. 128 36
      js/Kernel-Tests.deploy.js
  4. 157 50
      js/Kernel-Tests.js
  5. 9 1
      st/Kernel-Collections.st
  6. 100 10
      st/Kernel-Tests.st

+ 24 - 2
js/Kernel-Collections.deploy.js

@@ -2307,9 +2307,9 @@ smalltalk.method({
 selector: "putOn:",
 fn: function (aStream){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(aStream)._nextPutAll_(self);
+return smalltalk.withContext(function($ctx1) { 
_st(aStream)._nextPutString_(self);
 return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},smalltalk.CharacterArray)})},
-messageSends: ["nextPutAll:"]}),
+messageSends: ["nextPutString:"]}),
 smalltalk.CharacterArray);
 
 smalltalk.addMethod(
@@ -4010,6 +4010,17 @@ return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aCollection:aColle
 messageSends: ["do:", "nextPut:"]}),
 smalltalk.Stream);
 
+smalltalk.addMethod(
+"_nextPutString_",
+smalltalk.method({
+selector: "nextPutString:",
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._nextPut_(aString);
+return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.Stream)})},
+messageSends: ["nextPut:"]}),
+smalltalk.Stream);
+
 smalltalk.addMethod(
 "_peek",
 smalltalk.method({
@@ -4276,6 +4287,17 @@ return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aString:aString,pr
 messageSends: ["ifTrue:ifFalse:", "setCollection:", ",", "collection", "copyFrom:to:", "position", "+", "size", "atEnd", "position:", "setStreamSize:", "max:", "streamSize"]}),
 smalltalk.StringStream);
 
+smalltalk.addMethod(
+"_nextPutString_",
+smalltalk.method({
+selector: "nextPutString:",
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._nextPutAll_(aString);
+return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.StringStream)})},
+messageSends: ["nextPutAll:"]}),
+smalltalk.StringStream);
+
 smalltalk.addMethod(
 "_space",
 smalltalk.method({

+ 35 - 3
js/Kernel-Collections.js

@@ -3106,11 +3106,11 @@ selector: "putOn:",
 category: 'streaming',
 fn: function (aStream){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(aStream)._nextPutAll_(self);
+return smalltalk.withContext(function($ctx1) { 
_st(aStream)._nextPutString_(self);
 return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},smalltalk.CharacterArray)})},
 args: ["aStream"],
-source: "putOn: aStream\x0a\x09aStream nextPutAll: self",
-messageSends: ["nextPutAll:"],
+source: "putOn: aStream\x0a\x09aStream nextPutString: self",
+messageSends: ["nextPutString:"],
 referencedClasses: []
 }),
 smalltalk.CharacterArray);
@@ -5439,6 +5439,22 @@ referencedClasses: []
 }),
 smalltalk.Stream);
 
+smalltalk.addMethod(
+"_nextPutString_",
+smalltalk.method({
+selector: "nextPutString:",
+category: 'writing',
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._nextPut_(aString);
+return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.Stream)})},
+args: ["aString"],
+source: "nextPutString: aString\x0a\x09self nextPut: aString",
+messageSends: ["nextPut:"],
+referencedClasses: []
+}),
+smalltalk.Stream);
+
 smalltalk.addMethod(
 "_peek",
 smalltalk.method({
@@ -5801,6 +5817,22 @@ referencedClasses: []
 }),
 smalltalk.StringStream);
 
+smalltalk.addMethod(
+"_nextPutString_",
+smalltalk.method({
+selector: "nextPutString:",
+category: 'writing',
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
_st(self)._nextPutAll_(aString);
+return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.StringStream)})},
+args: ["aString"],
+source: "nextPutString: aString\x0a\x09self nextPutAll: aString",
+messageSends: ["nextPutAll:"],
+referencedClasses: []
+}),
+smalltalk.StringStream);
+
 smalltalk.addMethod(
 "_space",
 smalltalk.method({

+ 128 - 36
js/Kernel-Tests.deploy.js

@@ -3209,39 +3209,52 @@ messageSends: ["stream", "new", "collectionClass"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testAtEnd",
+"_testAtStartAtEnd",
 smalltalk.method({
-selector: "testAtEnd",
+selector: "testAtStartAtEnd",
 fn: function (){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.StreamTest)})},
-messageSends: []}),
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(self)._assert_(_st(stream)._atStart());
+_st(self)._assert_(_st(stream)._atEnd());
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+_st(self)._assert_(_st(stream)._atEnd());
+_st(self)._deny_(_st(stream)._atStart());
+_st(stream)._position_((1));
+_st(self)._deny_(_st(stream)._atEnd());
+_st(self)._deny_(_st(stream)._atStart());
+return self}, function($ctx1) {$ctx1.fill(self,"testAtStartAtEnd",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "assert:", "atStart", "atEnd", "nextPutAll:", "newCollection", "deny:", "position:"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testAtStart",
+"_testContents",
 smalltalk.method({
-selector: "testAtStart",
+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,"testAtStart",{stream:stream},smalltalk.StreamTest)})},
-messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+_st(self)._assert_equals_(_st(stream)._contents(),_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "nextPutAll:", "newCollection", "assert:equals:", "contents"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testContents",
+"_testIsEmpty",
 smalltalk.method({
-selector: "testContents",
+selector: "testIsEmpty",
 fn: function (){
 var self=this;
 var stream;
 return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(self)._assert_(_st(stream)._isEmpty());
 _st(stream)._nextPutAll_(_st(self)._newCollection());
-return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
-messageSends: ["newStream", "nextPutAll:", "newCollection"]}),
+_st(self)._deny_(_st(stream)._isEmpty());
+return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newStream", "assert:", "isEmpty", "nextPutAll:", "newCollection", "deny:"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
@@ -3250,11 +3263,19 @@ 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"]}),
+var collection,stream;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(collection);
+_st(self)._assert_equals_(_st(stream)._position(),_st(collection)._size());
+_st(stream)._position_((0));
+_st(self)._assert_equals_(_st(stream)._position(),(0));
+_st(stream)._next();
+_st(self)._assert_equals_(_st(stream)._position(),(1));
+_st(stream)._next();
+_st(self)._assert_equals_(_st(stream)._position(),(2));
+return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{collection:collection,stream:stream},smalltalk.StreamTest)})},
+messageSends: ["newCollection", "newStream", "nextPutAll:", "assert:equals:", "position", "size", "position:", "next"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
@@ -3263,8 +3284,19 @@ 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: []}),
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+$1=stream;
+_st($1)._nextPutAll_(collection);
+$2=_st($1)._position_((0));
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(self)._assert_equals_(_st(stream)._next(),each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_(_st(_st(stream)._next())._isNil());
+return self}, function($ctx1) {$ctx1.fill(self,"testReading",{stream:stream,collection:collection},smalltalk.StreamTest)})},
+messageSends: ["newCollection", "newStream", "nextPutAll:", "position:", "do:", "assert:equals:", "next", "assert:", "isNil"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
@@ -3283,8 +3315,15 @@ 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: []}),
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(stream).__lt_lt(each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{stream:stream,collection:collection},smalltalk.StreamTest)})},
+messageSends: ["newCollection", "newStream", "do:", "<<", "assert:equals:", "contents"]}),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
@@ -3293,21 +3332,18 @@ 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"]}),
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(stream)._nextPut_(each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(collection);
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{stream:stream,collection:collection},smalltalk.StreamTest)})},
+messageSends: ["newCollection", "newStream", "do:", "nextPut:", "assert:equals:", "contents", "nextPutAll:"]}),
 smalltalk.StreamTest);
 
 
@@ -3336,6 +3372,62 @@ messageSends: ["isNil", "collectionClass"]}),
 smalltalk.StreamTest.klass);
 
 
+smalltalk.addClass('ArrayStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=[true,(1),_st((3)).__at((4)),"foo"];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.ArrayStreamTest)})},
+messageSends: ["@"]}),
+smalltalk.ArrayStreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=(smalltalk.Array || Array);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayStreamTest.klass)})},
+messageSends: []}),
+smalltalk.ArrayStreamTest.klass);
+
+
+smalltalk.addClass('StringStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return "hello world";
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StringStreamTest)})},
+messageSends: []}),
+smalltalk.StringStreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=(smalltalk.String || String);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringStreamTest.klass)})},
+messageSends: []}),
+smalltalk.StringStreamTest.klass);
+
+
 smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_testCopying",

+ 157 - 50
js/Kernel-Tests.js

@@ -4135,52 +4135,65 @@ referencedClasses: []
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testAtEnd",
+"_testAtStartAtEnd",
 smalltalk.method({
-selector: "testAtEnd",
+selector: "testAtStartAtEnd",
 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: [],
+var stream;
+return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(self)._assert_(_st(stream)._atStart());
+_st(self)._assert_(_st(stream)._atEnd());
+_st(stream)._nextPutAll_(_st(self)._newCollection());
+_st(self)._assert_(_st(stream)._atEnd());
+_st(self)._deny_(_st(stream)._atStart());
+_st(stream)._position_((1));
+_st(self)._deny_(_st(stream)._atEnd());
+_st(self)._deny_(_st(stream)._atStart());
+return self}, function($ctx1) {$ctx1.fill(self,"testAtStartAtEnd",{stream:stream},smalltalk.StreamTest)})},
+args: [],
+source: "testAtStartAtEnd\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09self assert: stream atStart.\x0a\x09self assert: stream atEnd.\x0a\x09\x0a\x09stream nextPutAll: self newCollection.\x0a\x09self assert: stream atEnd.\x0a\x09self deny: stream atStart.\x0a\x09\x0a\x09stream position: 1.\x0a\x09self deny: stream atEnd.\x0a\x09self deny: stream atStart",
+messageSends: ["newStream", "assert:", "atStart", "atEnd", "nextPutAll:", "newCollection", "deny:", "position:"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testAtStart",
+"_testContents",
 smalltalk.method({
-selector: "testAtStart",
+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,"testAtStart",{stream:stream},smalltalk.StreamTest)})},
+_st(self)._assert_equals_(_st(stream)._contents(),_st(self)._newCollection());
+return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
 args: [],
-source: "testAtStart\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
-messageSends: ["newStream", "nextPutAll:", "newCollection"],
+source: "testContents\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.\x0a\x09\x0a\x09self assert: stream contents equals: self newCollection",
+messageSends: ["newStream", "nextPutAll:", "newCollection", "assert:equals:", "contents"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
 
 smalltalk.addMethod(
-"_testContents",
+"_testIsEmpty",
 smalltalk.method({
-selector: "testContents",
+selector: "testIsEmpty",
 category: 'tests',
 fn: function (){
 var self=this;
 var stream;
 return smalltalk.withContext(function($ctx1) { 
stream=_st(self)._newStream();
+_st(self)._assert_(_st(stream)._isEmpty());
 _st(stream)._nextPutAll_(_st(self)._newCollection());
-return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
+_st(self)._deny_(_st(stream)._isEmpty());
+return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{stream:stream},smalltalk.StreamTest)})},
 args: [],
-source: "testContents\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
-messageSends: ["newStream", "nextPutAll:", "newCollection"],
+source: "testIsEmpty\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09self assert: stream isEmpty.\x0a\x09\x0a\x09stream nextPutAll: self newCollection.\x0a\x09self deny: stream isEmpty",
+messageSends: ["newStream", "assert:", "isEmpty", "nextPutAll:", "newCollection", "deny:"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
@@ -4192,13 +4205,21 @@ 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)})},
+var collection,stream;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(collection);
+_st(self)._assert_equals_(_st(stream)._position(),_st(collection)._size());
+_st(stream)._position_((0));
+_st(self)._assert_equals_(_st(stream)._position(),(0));
+_st(stream)._next();
+_st(self)._assert_equals_(_st(stream)._position(),(1));
+_st(stream)._next();
+_st(self)._assert_equals_(_st(stream)._position(),(2));
+return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{collection:collection,stream:stream},smalltalk.StreamTest)})},
 args: [],
-source: "testPosition\x0a\x09| stream |\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.",
-messageSends: ["newStream", "nextPutAll:", "newCollection"],
+source: "testPosition\x0a\x09| collection stream |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09stream nextPutAll: collection.\x0a\x09self assert: stream position equals: collection size.\x0a\x09\x0a\x09stream position: 0.\x0a\x09self assert: stream position equals: 0.\x0a\x09\x0a\x09stream next.\x0a\x09self assert: stream position equals: 1.\x0a\x09\x0a\x09stream next.\x0a\x09self assert: stream position equals: 2",
+messageSends: ["newCollection", "newStream", "nextPutAll:", "assert:equals:", "position", "size", "position:", "next"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
@@ -4210,10 +4231,21 @@ selector: "testReading",
 category: 'tests',
 fn: function (){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testReading",{},smalltalk.StreamTest)})},
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+$1=stream;
+_st($1)._nextPutAll_(collection);
+$2=_st($1)._position_((0));
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(self)._assert_equals_(_st(stream)._next(),each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_(_st(_st(stream)._next())._isNil());
+return self}, function($ctx1) {$ctx1.fill(self,"testReading",{stream:stream,collection:collection},smalltalk.StreamTest)})},
 args: [],
-source: "testReading",
-messageSends: [],
+source: "testReading\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09stream \x0a\x09\x09nextPutAll: collection;\x0a\x09\x09position: 0.\x0a\x09\x0a\x09collection do: [ :each |\x0a\x09\x09self assert: stream next equals: each ].\x0a\x09\x09\x0a\x09self assert: stream next isNil",
+messageSends: ["newCollection", "newStream", "nextPutAll:", "position:", "do:", "assert:equals:", "next", "assert:", "isNil"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
@@ -4240,10 +4272,17 @@ selector: "testWrite",
 category: 'tests',
 fn: function (){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{},smalltalk.StreamTest)})},
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(stream).__lt_lt(each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{stream:stream,collection:collection},smalltalk.StreamTest)})},
 args: [],
-source: "testWrite",
-messageSends: [],
+source: "testWrite\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09collection do: [ :each | stream << each ].\x0a\x09self assert: stream contents equals: collection",
+messageSends: ["newCollection", "newStream", "do:", "<<", "assert:equals:", "contents"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
@@ -4255,28 +4294,20 @@ 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"],
+var stream,collection;
+return smalltalk.withContext(function($ctx1) { 
collection=_st(self)._newCollection();
+stream=_st(self)._newStream();
+_st(collection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
return _st(stream)._nextPut_(each);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+stream=_st(self)._newStream();
+_st(stream)._nextPutAll_(collection);
+_st(self)._assert_equals_(_st(stream)._contents(),collection);
+return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{stream:stream,collection:collection},smalltalk.StreamTest)})},
+args: [],
+source: "testWriting\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09collection do: [ :each | stream nextPut: each ].\x0a\x09self assert: stream contents equals: collection.\x0a\x09\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: collection.\x0a\x09self assert: stream contents equals: collection",
+messageSends: ["newCollection", "newStream", "do:", "nextPut:", "assert:equals:", "contents", "nextPutAll:"],
 referencedClasses: []
 }),
 smalltalk.StreamTest);
@@ -4317,6 +4348,82 @@ referencedClasses: []
 smalltalk.StreamTest.klass);
 
 
+smalltalk.addClass('ArrayStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=[true,(1),_st((3)).__at((4)),"foo"];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.ArrayStreamTest)})},
+args: [],
+source: "newCollection\x0a\x09^ { true. 1. 3@4. 'foo' }",
+messageSends: ["@"],
+referencedClasses: []
+}),
+smalltalk.ArrayStreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=(smalltalk.Array || Array);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayStreamTest.klass)})},
+args: [],
+source: "collectionClass\x0a\x09^ Array",
+messageSends: [],
+referencedClasses: ["Array"]
+}),
+smalltalk.ArrayStreamTest.klass);
+
+
+smalltalk.addClass('StringStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_newCollection",
+smalltalk.method({
+selector: "newCollection",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return "hello world";
+}, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StringStreamTest)})},
+args: [],
+source: "newCollection\x0a\x09^ 'hello world'",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.StringStreamTest);
+
+
+smalltalk.addMethod(
+"_collectionClass",
+smalltalk.method({
+selector: "collectionClass",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=(smalltalk.String || String);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringStreamTest.klass)})},
+args: [],
+source: "collectionClass\x0a\x09^ String",
+messageSends: [],
+referencedClasses: ["String"]
+}),
+smalltalk.StringStreamTest.klass);
+
+
 smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 "_testCopying",

+ 9 - 1
st/Kernel-Collections.st

@@ -1077,7 +1077,7 @@ printOn: aStream
 !CharacterArray methodsFor: 'streaming'!
 
 putOn: aStream
-	aStream nextPutAll: self
+	aStream nextPutString: self
 ! !
 
 !CharacterArray class methodsFor: 'instance creation'!
@@ -1874,6 +1874,10 @@ nextPutAll: aCollection
 		self nextPut: each]
 !
 
+nextPutString: aString
+	self nextPut: aString
+!
+
 write: anObject
 	anObject putOn: self
 ! !
@@ -1933,6 +1937,10 @@ nextPutAll: aString
 	self setStreamSize: (self streamSize max: self position)
 !
 
+nextPutString: aString
+	self nextPutAll: aString
+!
+
 space
 	self nextPut: ' '
 !

+ 100 - 10
st/Kernel-Tests.st

@@ -1656,43 +1656,101 @@ newStream
 
 !StreamTest methodsFor: 'tests'!
 
-testAtEnd
-!
-
-testAtStart
+testAtStartAtEnd
 	| stream |
+	
 	stream := self newStream.
+	self assert: stream atStart.
+	self assert: stream atEnd.
+	
 	stream nextPutAll: self newCollection.
+	self assert: stream atEnd.
+	self deny: stream atStart.
+	
+	stream position: 1.
+	self deny: stream atEnd.
+	self deny: stream atStart
 !
 
 testContents
 	| stream |
+	
 	stream := self newStream.
 	stream nextPutAll: self newCollection.
+	
+	self assert: stream contents equals: self newCollection
 !
 
-testPosition
+testIsEmpty
 	| stream |
+	
 	stream := self newStream.
+	self assert: stream isEmpty.
+	
 	stream nextPutAll: self newCollection.
+	self deny: stream isEmpty
+!
+
+testPosition
+	| collection stream |
+	
+	collection := self newCollection.
+	stream := self newStream.
+	
+	stream nextPutAll: collection.
+	self assert: stream position equals: collection size.
+	
+	stream position: 0.
+	self assert: stream position equals: 0.
+	
+	stream next.
+	self assert: stream position equals: 1.
+	
+	stream next.
+	self assert: stream position equals: 2
 !
 
 testReading
+	| stream collection |
+	
+	collection := self newCollection.
+	stream := self newStream.
+	
+	stream 
+		nextPutAll: collection;
+		position: 0.
+	
+	collection do: [ :each |
+		self assert: stream next equals: each ].
+		
+	self assert: stream next isNil
 !
 
 testStreamContents
 !
 
 testWrite
+	| stream collection |
+	
+	collection := self newCollection.
+	stream := self newStream.
+	
+	collection do: [ :each | stream << each ].
+	self assert: stream contents equals: collection
 !
 
 testWriting
-!
-
-testisEmpty
-	| stream |
+	| stream collection |
+	
+	collection := self newCollection.
 	stream := self newStream.
-	stream nextPutAll: self newCollection.
+	
+	collection do: [ :each | stream nextPut: each ].
+	self assert: stream contents equals: collection.
+	
+	stream := self newStream.
+	stream nextPutAll: collection.
+	self assert: stream contents equals: collection
 ! !
 
 !StreamTest class methodsFor: 'accessing'!
@@ -1707,6 +1765,38 @@ isAbstract
 	^ self collectionClass isNil
 ! !
 
+StreamTest subclass: #ArrayStreamTest
+	instanceVariableNames: ''
+	package: 'Kernel-Tests'!
+
+!ArrayStreamTest methodsFor: 'accessing'!
+
+newCollection
+	^ { true. 1. 3@4. 'foo' }
+! !
+
+!ArrayStreamTest class methodsFor: 'accessing'!
+
+collectionClass
+	^ Array
+! !
+
+StreamTest subclass: #StringStreamTest
+	instanceVariableNames: ''
+	package: 'Kernel-Tests'!
+
+!StringStreamTest methodsFor: 'accessing'!
+
+newCollection
+	^ 'hello world'
+! !
+
+!StringStreamTest class methodsFor: 'accessing'!
+
+collectionClass
+	^ String
+! !
+
 TestCase subclass: #UndefinedTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!