RegressionTests__StreamTests.st
changeset 2188 11bf104c2bdd
parent 2165 1fc8dd893e6c
child 2190 df0e2fac468d
equal deleted inserted replaced
2187:40d7bf5c68b4 2188:11bf104c2bdd
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'stx:goodies/regression' }"
     3 "{ Package: 'stx:goodies/regression' }"
     2 
     4 
     3 "{ NameSpace: RegressionTests }"
     5 "{ NameSpace: RegressionTests }"
     4 
     6 
     5 TestCase subclass:#StreamTests
     7 TestCase subclass:#StreamTests
   727 
   729 
   728 test50_skipThrough
   730 test50_skipThrough
   729     |s|
   731     |s|
   730 
   732 
   731          "0123456789012345678901"
   733          "0123456789012345678901"
   732     s := '0123456789012345678901' readStream.
   734     {     
   733     self assert:(s position == 0).
   735         '0123456789012345678901' asArray.
   734     s skipThrough:$0.
   736         '0123456789012345678901' asArray asOrderedCollection.
   735     self assert:(s peek == $1).
   737         '0123456789012345678901' .
   736     self assert:(s position == 1).
   738         '0123456789012345678901' asUnicode16String .
   737 
   739         '0123456789012345678901' asUnicode32String .
   738     s skipThrough:$0.
   740     } do:[:eachInput |    
   739     self assert:(s peek == $1).
   741         s := eachInput readStream.
   740     self assert:(s position == 11).
   742         self assert:(s position == 0).
   741 
   743         s skipThrough:$0.
   742     s skipThrough:$0.
   744         self assert:(s peek == $1).
   743     self assert:(s peek == $1).
   745         self assert:(s position == 1).
   744     self assert:(s position == 21).
   746 
   745 
   747         s skipThrough:$0.
   746     s := 'bla { foo }' readStream.
   748         self assert:(s peek == $1).
   747     s skipThrough:${.
   749         self assert:(s position == 11).
   748     self assert:(s peek == $ ).
   750 
   749     s skipThrough:$}.
   751         s skipThrough:$0.
   750     self assert:(s atEnd).
   752         self assert:(s peek == $1).
   751 
   753         self assert:(s position == 21).
       
   754 
       
   755         s := 'bla { foo }' readStream.
       
   756         s skipThrough:${.
       
   757         self assert:(s peek == $ ).
       
   758         s skipThrough:$}.
       
   759         self assert:(s atEnd).
       
   760     ].
       
   761     
   752     "
   762     "
   753      self run:#test50_skipThrough
   763      self run:#test50_skipThrough
   754      self new test50_skipThrough
   764      self new test50_skipThrough
   755     "
   765     "
       
   766 
       
   767     "Modified: / 27-03-2019 / 14:50:19 / Claus Gittinger"
       
   768 !
       
   769 
       
   770 test51_skipSeparators
       
   771     |s next|
       
   772 
       
   773     {   
       
   774         "1234567890123456789"
       
   775         '0   1   2         3' asArray .
       
   776         '0   1   2         3' asArray asOrderedCollection.
       
   777         '0   1   2         3' .
       
   778         '0   1   2         3' asUnicode16String .
       
   779         '0   1   2         3' asUnicode32String .
       
   780     } do:[:eachInput |
       
   781         s := eachInput readStream.
       
   782         next := s skipSeparators.
       
   783         self assert:(s position == 0).
       
   784         self assert:(next == $0).
       
   785         self assert:(s peek == $0).
       
   786         self assert:(s skipSeparators == $0).
       
   787         self assert:(s position == 0).
       
   788         self assert:(s peek == $0).
       
   789         self assert:(s position == 0).
       
   790         self assert:(s next == $0).
       
   791         self assert:(s position == 1).
       
   792 
       
   793         next := s skipSeparators.
       
   794         self assert:(s position == 4).
       
   795         self assert:(next == $1).
       
   796         self assert:(s peek == $1).
       
   797         self assert:(s skipSeparators == $1).
       
   798         self assert:(s position == 4).
       
   799         self assert:(s peek == $1).
       
   800         self assert:(s position == 4).
       
   801         self assert:(s next == $1).
       
   802         self assert:(s position == 5).
       
   803         
       
   804         next := s skipSeparators.
       
   805         self assert:(s position == 8).
       
   806         self assert:(next == $2).
       
   807         self assert:(s peek == $2).
       
   808         self assert:(s skipSeparators == $2).
       
   809         self assert:(s position == 8).
       
   810         self assert:(s peek == $2).
       
   811         self assert:(s position == 8).
       
   812         self assert:(s next == $2).
       
   813         self assert:(s position == 9).
       
   814 
       
   815         next := s skipSeparators.
       
   816         self assert:(s position == 18).
       
   817         self assert:(next == $3).
       
   818         self assert:(s peek == $3).
       
   819         self assert:(s skipSeparators == $3).
       
   820         self assert:(s position == 18).
       
   821         self assert:(s peek == $3).
       
   822         self assert:(s position == 18).
       
   823         self assert:(s next == $3).
       
   824         self assert:(s position == 19).
       
   825 
       
   826         self assert:(s atEnd).
       
   827     ].
       
   828     
       
   829     {   
       
   830         "1234567890123456789"
       
   831         '0                  ' asArray.
       
   832         '0                  ' asArray asOrderedCollection.
       
   833         '0                  ' .
       
   834         '0                  ' asUnicode16String .
       
   835         '0                  ' asUnicode32String .
       
   836     } do:[:eachInput |
       
   837         s := eachInput readStream.
       
   838         next := s skipSeparators.
       
   839         self assert:(s position == 0).
       
   840         self assert:(next == $0).
       
   841         self assert:(s peek == $0).
       
   842         self assert:(s skipSeparators == $0).
       
   843         self assert:(s position == 0).
       
   844         self assert:(s peek == $0).
       
   845         self assert:(s position == 0).
       
   846         self assert:(s next == $0).
       
   847         self assert:(s position == 1).
       
   848 
       
   849         next := s skipSeparators.
       
   850         self assert:(s position == 19).
       
   851         self assert:(next isNil).
       
   852         self assert:(s peek isNil).
       
   853         self assert:(s skipSeparators isNil).
       
   854         self assert:(s position == 19).
       
   855         self assert:(s peek isNil).
       
   856         self assert:(s position == 19).
       
   857         self assert:(s next isNil).
       
   858         self assert:(s position == 19).
       
   859         
       
   860         self assert:(s atEnd).
       
   861     ].
       
   862 
       
   863     {   
       
   864         "12345678901234567890"
       
   865         '0                  x' asArray.
       
   866         '0                  x' asArray asOrderedCollection.
       
   867         '0                  x' .
       
   868         '0                  x' asUnicode16String .
       
   869         '0                  x' asUnicode32String .
       
   870     } do:[:eachInput |
       
   871         s := eachInput readStream.
       
   872         s readLimit:19.
       
   873         
       
   874         next := s skipSeparators.
       
   875         self assert:(s position == 0).
       
   876         self assert:(next == $0).
       
   877         self assert:(s peek == $0).
       
   878         self assert:(s skipSeparators == $0).
       
   879         self assert:(s position == 0).
       
   880         self assert:(s peek == $0).
       
   881         self assert:(s position == 0).
       
   882         self assert:(s next == $0).
       
   883         self assert:(s position == 1).
       
   884 
       
   885         next := s skipSeparators.
       
   886         self assert:(s position == 19).
       
   887         self assert:(next isNil).
       
   888         self assert:(s peek isNil).
       
   889         self assert:(s skipSeparators isNil).
       
   890         self assert:(s position == 19).
       
   891         self assert:(s peek isNil).
       
   892         self assert:(s position == 19).
       
   893         self assert:(s next isNil).
       
   894         self assert:(s position == 19).
       
   895 
       
   896         self assert:(s atEnd).
       
   897     ].
       
   898 
       
   899     {   
       
   900         "12345678901234567890"
       
   901         '0                   ' asArray.
       
   902         '0                   ' asArray asOrderedCollection.
       
   903         '0                   ' .
       
   904         '0                   ' asUnicode16String .
       
   905         '0                   ' asUnicode32String .
       
   906     } do:[:eachInput |
       
   907         s := eachInput readStream.
       
   908         s readLimit:19.
       
   909 
       
   910         next := s skipSeparators.
       
   911         self assert:(s position == 0).
       
   912         self assert:(next == $0).
       
   913         self assert:(s peek == $0).
       
   914         self assert:(s skipSeparators == $0).
       
   915         self assert:(s position == 0).
       
   916         self assert:(s peek == $0).
       
   917         self assert:(s position == 0).
       
   918         self assert:(s next == $0).
       
   919         self assert:(s position == 1).
       
   920 
       
   921         next := s skipSeparators.
       
   922         self assert:(s position == 19).
       
   923         self assert:(next isNil).
       
   924         self assert:(s peek isNil).
       
   925         self assert:(s skipSeparators isNil).
       
   926         self assert:(s position == 19).
       
   927         self assert:(s peek isNil).
       
   928         self assert:(s position == 19).
       
   929         self assert:(s next isNil).
       
   930         self assert:(s position == 19).
       
   931 
       
   932         self assert:(s atEnd).
       
   933     ].
       
   934     "
       
   935      self run:#test51_skipSeparators
       
   936      self new test51_skipSeparators
       
   937     "
       
   938 
       
   939     "Created: / 27-03-2019 / 14:44:14 / Claus Gittinger"
   756 ! !
   940 ! !
   757 
   941 
   758 !StreamTests class methodsFor:'documentation'!
   942 !StreamTests class methodsFor:'documentation'!
   759 
   943 
   760 version
   944 version