#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Mon, 01 Apr 2019 17:20:34 +0200
changeset 2206 827d17b7a941
parent 2205 abbfea7d603b
child 2207 33fec8c61cb8
#QUALITY by cg class: RegressionTests::StreamTests changed: #test09_writeStreamErrors
RegressionTests__StreamTests.st
--- a/RegressionTests__StreamTests.st	Fri Mar 29 15:13:26 2019 +0100
+++ b/RegressionTests__StreamTests.st	Mon Apr 01 17:20:34 2019 +0200
@@ -370,16 +370,87 @@
 !
 
 test09_writeStreamErrors
-    |s|
+    |s didRaise|
 
     s := '' writeStream.
     self should:[ s nextPutAll:nil ] raise:Error.
     self assert:( s contents = '' ).
 
+    "/ write error must be raised
+    s := '' writeStream.
+    s writeLimit:5.
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s nextPutAll:'1234567890'.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+
+    "/ try more
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s nextPut:$6.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+
+    "/ try more
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s space.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+    
+    "/ try more
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s cr.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+
+    "/ try more
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s next:10 put:$9.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+
+    "/ try more
+    didRaise := false.
+    WriteError handle:[:ex |
+        didRaise := true.
+        ex return.
+    ] do:[    
+        s nextPutAll:'6789012345' startingAt:1 to:10.
+    ].
+    self assert:didRaise.
+    self assert:(s contents size == 5).
+
+    
     "
      self run:#test09_writeStreamErrors
      self new test09_writeStreamErrors
     "
+
+    "Modified: / 01-04-2019 / 17:13:40 / Claus Gittinger"
 !
 
 test20_readWriteStream