| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | USING: arrays byte-arrays kernel kernel.private math memory | 
					
						
							|  |  |  | namespaces sequences tools.test math.private quotations | 
					
						
							| 
									
										
										
										
											2008-01-17 04:03:09 -05:00
										 |  |  | continuations prettyprint io.streams.string debugger assocs ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: kernel.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 0 ] [ f size ] unit-test | 
					
						
							|  |  |  | [ t ] [ [ \ = \ = ] all-equal? ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Don't leak extra roots if error is thrown | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ ] [ 10000 [ [ 3 throw ] ignore-errors ] times ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ ] [ 10000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Make sure we report the correct error on stack underflow | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ clear drop ] [ { "kernel-error" 11 f f } = ] must-fail-with | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ { } set-retainstack r> ] [ { "kernel-error" 13 f f } = ] must-fail-with | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : overflow-d 3 overflow-d ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ overflow-d ] [ { "kernel-error" 12 f f } = ] must-fail-with | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : (overflow-d-alt) 3 ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : overflow-d-alt (overflow-d-alt) overflow-d-alt ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ overflow-d-alt ] [ { "kernel-error" 12 f f } = ] must-fail-with | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-15 23:20:31 -05:00
										 |  |  | [ ] [ [ :c ] with-string-writer drop ] unit-test | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : overflow-r 3 >r overflow-r ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ overflow-r ] [ { "kernel-error" 14 f f } = ] must-fail-with | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ -7 <byte-array> ] must-fail | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 2 3 4 1 ] [ 1 2 3 4 roll ] unit-test | 
					
						
							|  |  |  | [ 1 2 3 4 ] [ 2 3 4 1 -roll ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 3 ] [ t 3 and ] unit-test | 
					
						
							|  |  |  | [ f ] [ f 3 and ] unit-test | 
					
						
							|  |  |  | [ f ] [ 3 f and ] unit-test | 
					
						
							|  |  |  | [ 4 ] [ 4 6 or ] unit-test | 
					
						
							|  |  |  | [ 6 ] [ f 6 or ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ slip ] must-fail | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ 1 slip ] must-fail | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ 1 2 slip ] must-fail | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ 1 2 3 slip ] must-fail | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 5 ] [ [ 2 2 + ] 1 slip + ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ [ ] keep ] must-fail | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 6 ] [ 2 [ sq ] keep + ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ [ ] 2keep ] must-fail | 
					
						
							|  |  |  | [ 1 [ ] 2keep ] must-fail | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ 3 1 2 ] [ 1 2 [ 2drop 3 ] 2keep ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 0 ] [ f [ sq ] [ 0 ] if* ] unit-test | 
					
						
							|  |  |  | [ 4 ] [ 2 [ sq ] [ 0 ] if* ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 0 ] [ f [ 0 ] unless* ] unit-test | 
					
						
							|  |  |  | [ t ] [ t [ "Hello" ] unless* ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-15 23:20:31 -05:00
										 |  |  | [ "2\n" ] [ [ 1 2 [ . ] [ sq . ] ?if ] with-string-writer ] unit-test | 
					
						
							|  |  |  | [ "9\n" ] [ [ 3 f [ . ] [ sq . ] ?if ] with-string-writer ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ f (clone) ] unit-test | 
					
						
							|  |  |  | [ -123 ] [ -123 (clone) ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 6 2 ] [ 1 2 [ 5 + ] dip ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ callstack set-callstack ] unit-test | 
					
						
							| 
									
										
										
										
											2007-10-03 17:11:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ 3drop datastack ] must-fail | 
					
						
							| 
									
										
										
										
											2007-10-07 00:12:02 -04:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							| 
									
										
										
										
											2007-12-24 20:56:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Doesn't compile; important | 
					
						
							|  |  |  | : foo 5 + 0 [ ] each ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ drop foo ] must-fail | 
					
						
							| 
									
										
										
										
											2007-12-24 20:56:23 -05:00
										 |  |  | [ ] [ :c ] unit-test | 
					
						
							| 
									
										
										
										
											2008-01-13 18:52:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Regression | 
					
						
							|  |  |  | : (loop) ( a b c d -- )
 | 
					
						
							|  |  |  |     >r pick r> swap >r pick r> swap
 | 
					
						
							|  |  |  |     < [ >r >r >r 1+ r> r> r> (loop) ] [ 2drop 2drop ] if ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : loop ( obj obj -- )
 | 
					
						
							|  |  |  |     H{ } values swap >r dup length swap r> 0 -roll (loop) ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ loop ] must-fail | 
					
						
							| 
									
										
										
										
											2008-04-07 00:31:53 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Discovered on Windows | 
					
						
							|  |  |  | : total-failure-1 "" [ ] map unimplemented ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ total-failure-1 ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : total-failure-2 [ ] (call) unimplemented ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ total-failure-2 ] must-fail |