| 
									
										
										
										
											2008-06-29 03:12:44 -04:00
										 |  |  | USING: mirrors tools.test assocs kernel arrays accessors words | 
					
						
							| 
									
										
										
										
											2008-07-29 01:05:01 -04:00
										 |  |  | namespaces math slots parser eval ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: mirrors.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | TUPLE: foo bar baz ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | C: <foo> foo | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-03 07:05:50 -04:00
										 |  |  | [ 2 ] [ 1 2 <foo> <mirror> assoc-size ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-01 17:33:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-03 07:05:50 -04:00
										 |  |  | [ { "bar" "baz" } ] [ 1 2 <foo> <mirror> keys ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-07 03:29:00 -05:00
										 |  |  | [ 1 t ] [ "bar" 1 2 <foo> <mirror> at* ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ f f ] [ "hi" 1 2 <foo> <mirror> at* ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 3 ] [ | 
					
						
							| 
									
										
										
										
											2008-09-02 02:53:37 -04:00
										 |  |  |     3 "baz" 1 2 <foo> [ <mirror> set-at ] keep baz>> | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-24 03:48:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 03:12:44 -04:00
										 |  |  | [ 3 "hi" 1 2 <foo> <mirror> set-at ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 3 "numerator" 1/2 <mirror> set-at ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "foo" ] [ | 
					
						
							|  |  |  |     gensym [ | 
					
						
							|  |  |  |         <mirror> [ | 
					
						
							|  |  |  |             "foo" "name" set
 | 
					
						
							|  |  |  |         ] bind | 
					
						
							|  |  |  |     ] [ name>> ] bi
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ gensym <mirror> [ "compiled" off ] bind ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: declared-mirror-test | 
					
						
							| 
									
										
										
										
											2008-06-29 22:37:57 -04:00
										 |  |  | { a integer initial: 0 } ;
 | 
					
						
							| 
									
										
										
										
											2008-06-29 03:12:44 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 5 ] [ | 
					
						
							|  |  |  |     3 declared-mirror-test boa <mirror> [ | 
					
						
							|  |  |  |         5 "a" set
 | 
					
						
							|  |  |  |         "a" get
 | 
					
						
							|  |  |  |     ] bind | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 3 declared-mirror-test boa <mirror> [ t "a" set ] bind ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: color | 
					
						
							| 
									
										
										
										
											2008-06-29 22:37:57 -04:00
										 |  |  | { red integer } | 
					
						
							|  |  |  | { green integer } | 
					
						
							|  |  |  | { blue integer } ;
 | 
					
						
							| 
									
										
										
										
											2008-06-29 03:12:44 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ T{ color f 0 0 0 } ] [ | 
					
						
							|  |  |  |     1 2 3 color boa [ <mirror> clear-assoc ] keep
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-01 17:16:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Test reshaping with a mirror | 
					
						
							|  |  |  | 1 2 3 color boa <mirror> "mirror" set
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-17 16:49:21 -04:00
										 |  |  | [ ] [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-01 17:16:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 1 ] [ "red" "mirror" get at ] unit-test |