| 
									
										
										
										
											2008-12-14 22:21:44 -05:00
										 |  |  | USING: tools.test io.files io.files.private io.files.temp | 
					
						
							|  |  |  | io.directories io.encodings.8-bit arrays make system | 
					
						
							| 
									
										
										
										
											2009-01-29 01:08:40 -05:00
										 |  |  | io.encodings.binary io threads kernel continuations | 
					
						
							|  |  |  | io.encodings.ascii sequences strings accessors | 
					
						
							|  |  |  | io.encodings.utf8 math destructors namespaces ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: io.files.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-11 18:43:11 -04:00
										 |  |  | \ exists? must-infer | 
					
						
							|  |  |  | \ (exists?) must-infer | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  | [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test | 
					
						
							| 
									
										
										
										
											2008-02-27 15:59:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  | [ ] [ "append-test" temp-file ascii <file-appender> dispose ] unit-test | 
					
						
							| 
									
										
										
										
											2008-02-27 15:59:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  | [ | 
					
						
							|  |  |  |     "This is a line.\rThis is another line.\r" | 
					
						
							|  |  |  | ] [ | 
					
						
							|  |  |  |     "resource:core/io/test/mac-os-eol.txt" latin1 <file-reader> | 
					
						
							|  |  |  |     [ 500 read ] with-input-stream
 | 
					
						
							| 
									
										
										
										
											2008-02-27 15:59:15 -05:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  | [ | 
					
						
							|  |  |  |     255
 | 
					
						
							|  |  |  | ] [ | 
					
						
							|  |  |  |     "resource:core/io/test/binary.txt" latin1 <file-reader> | 
					
						
							|  |  |  |     [ read1 ] with-input-stream >fixnum
 | 
					
						
							| 
									
										
										
										
											2008-02-27 15:59:15 -05:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  |     "It seems Jobs has lost his grasp on reality again.\n" | 
					
						
							|  |  |  |     "separator-test.txt" temp-file latin1 set-file-contents | 
					
						
							| 
									
										
										
										
											2008-03-26 20:40:40 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-27 21:10:47 -04:00
										 |  |  | [ | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  |     { | 
					
						
							|  |  |  |         { "It seems " CHAR: J } | 
					
						
							|  |  |  |         { "obs has lost h" CHAR: i } | 
					
						
							|  |  |  |         { "s grasp on reality again.\n" f } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         "separator-test.txt" temp-file | 
					
						
							|  |  |  |         latin1 <file-reader> [ | 
					
						
							|  |  |  |             "J" read-until 2array , | 
					
						
							|  |  |  |             "i" read-until 2array , | 
					
						
							|  |  |  |             "X" read-until 2array , | 
					
						
							|  |  |  |         ] with-input-stream
 | 
					
						
							|  |  |  |     ] { } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     image binary [ | 
					
						
							|  |  |  |         10 [ 65536 read drop ] times
 | 
					
						
							|  |  |  |     ] with-file-reader | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Test EOF behavior | 
					
						
							|  |  |  | [ 10 ] [ | 
					
						
							|  |  |  |     image binary [ | 
					
						
							|  |  |  |         0 read drop
 | 
					
						
							|  |  |  |         10 read length
 | 
					
						
							|  |  |  |     ] with-file-reader | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-12-14 22:21:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | USE: debugger.threads | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "test-quux.txt" temp-file delete-file ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ "quux-test.txt" temp-file exists? ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "quux-test.txt" temp-file delete-file ] unit-test |