| 
									
										
										
										
											2008-09-11 01:20:06 -04:00
										 |  |  | USING: io.streams.string io kernel arrays namespaces make | 
					
						
							|  |  |  | tools.test ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: io.streams.string.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-10 17:39:51 -04:00
										 |  |  | [ "" ] [ "" [ contents ] with-string-reader ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "line 1" CHAR: l ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     "line 1\nline 2\nline 3" <string-reader> | 
					
						
							|  |  |  |     dup stream-readln swap stream-read1
 | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ f ] | 
					
						
							|  |  |  | [ "" <string-reader> stream-readln ] | 
					
						
							|  |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-15 23:20:31 -05:00
										 |  |  | [ "xyzzy" ] [ [ "xyzzy" write ] with-string-writer ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-27 01:53:05 -05:00
										 |  |  | [ "a" ] [ 1 "abc" <string-reader> stream-read ] unit-test | 
					
						
							|  |  |  | [ "ab" ] [ 2 "abc" <string-reader> stream-read ] unit-test | 
					
						
							|  |  |  | [ "abc" ] [ 3 "abc" <string-reader> stream-read ] unit-test | 
					
						
							|  |  |  | [ "abc" ] [ 4 "abc" <string-reader> stream-read ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "abc" f ] [ | 
					
						
							| 
									
										
										
										
											2009-02-27 01:53:05 -05:00
										 |  |  |     3 "abc" <string-reader> [ stream-read ] keep stream-read1
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         { "It seems " CHAR: J } | 
					
						
							|  |  |  |         { "obs has lost h" CHAR: i } | 
					
						
							|  |  |  |         { "s grasp on reality again.\n" f } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         "It seems Jobs has lost his grasp on reality again.\n" | 
					
						
							|  |  |  |         <string-reader> [ | 
					
						
							|  |  |  |             "J" read-until 2array , | 
					
						
							|  |  |  |             "i" read-until 2array , | 
					
						
							|  |  |  |             "X" read-until 2array , | 
					
						
							| 
									
										
										
										
											2008-05-05 03:19:25 -04:00
										 |  |  |         ] with-input-stream
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |     ] { } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "hello" "hi" ] [ | 
					
						
							|  |  |  |     "hello\nhi" <string-reader> | 
					
						
							|  |  |  |     dup stream-readln
 | 
					
						
							|  |  |  |     2 rot stream-read
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "hello" "hi" ] [ | 
					
						
							|  |  |  |     "hello\r\nhi" <string-reader> | 
					
						
							|  |  |  |     dup stream-readln
 | 
					
						
							|  |  |  |     2 rot stream-read
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "hello" "hi" ] [ | 
					
						
							|  |  |  |     "hello\rhi" <string-reader> | 
					
						
							|  |  |  |     dup stream-readln
 | 
					
						
							|  |  |  |     2 rot stream-read
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2011-09-08 20:24:05 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Issue #70 github | 
					
						
							|  |  |  | [ f ] [ "" [ 0 read ] with-string-reader ] unit-test | 
					
						
							|  |  |  | [ f ] [ "" [ 1 read ] with-string-reader ] unit-test | 
					
						
							|  |  |  | [ f ] [ "" [ readln ] with-string-reader ] unit-test | 
					
						
							|  |  |  | [ "\"\"" ] [ "\"\"" [ readln ] with-string-reader ] unit-test |