| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | USING: alien arrays definitions generic assocs hashtables io | 
					
						
							|  |  |  | kernel math namespaces parser prettyprint sequences strings | 
					
						
							| 
									
										
										
										
											2008-03-19 16:24:49 -04:00
										 |  |  | tools.test vectors words quotations classes | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | classes.private classes.union classes.mixin classes.predicate | 
					
						
							| 
									
										
										
										
											2008-03-24 20:52:21 -04:00
										 |  |  | classes.algebra vectors definitions source-files | 
					
						
							| 
									
										
										
										
											2008-06-12 06:49:46 -04:00
										 |  |  | compiler.units kernel.private sorting vocabs ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: classes.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-05 17:24:32 -05:00
										 |  |  | ! DEFER: bah | 
					
						
							|  |  |  | ! FORGET: bah | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | UNION: bah fixnum alien ;
 | 
					
						
							|  |  |  | [ bah ] [ \ bah? "predicating" word-prop ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Test redefinition of classes | 
					
						
							|  |  |  | UNION: union-1 fixnum float ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GENERIC: generic-update-test ( x -- y )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: union-1 generic-update-test drop "union-1" ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ f ] [ bignum union-1 class<= ] unit-test | 
					
						
							|  |  |  | [ t ] [ union-1 number class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "union-1" ] [ 1.0 generic-update-test ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | "IN: classes.tests USE: math USE: arrays UNION: union-1 rational array ;" eval | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ bignum union-1 class<= ] unit-test | 
					
						
							|  |  |  | [ f ] [ union-1 number class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "union-1" ] [ { 1.0 } generic-update-test ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-26 19:23:19 -04:00
										 |  |  | "IN: classes.tests USE: math PREDICATE: union-1 < integer even? ;" eval | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ union-1 union-class? ] unit-test | 
					
						
							|  |  |  | [ t ] [ union-1 predicate-class? ] unit-test | 
					
						
							|  |  |  | [ "union-1" ] [ 8 generic-update-test ] unit-test | 
					
						
							| 
									
										
										
										
											2008-02-06 14:47:19 -05:00
										 |  |  | [ -7 generic-update-test ] must-fail | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Test mixins | 
					
						
							|  |  |  | MIXIN: sequence-mixin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | INSTANCE: array sequence-mixin | 
					
						
							|  |  |  | INSTANCE: vector sequence-mixin | 
					
						
							|  |  |  | INSTANCE: slice sequence-mixin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MIXIN: assoc-mixin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | INSTANCE: hashtable assoc-mixin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GENERIC: collection-size ( x -- y )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: sequence-mixin collection-size length ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: assoc-mixin collection-size assoc-size ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ array sequence-mixin class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ t ] [ { 1 2 3 } sequence-mixin? ] unit-test | 
					
						
							|  |  |  | [ 3 ] [ { 1 2 3 } collection-size ] unit-test | 
					
						
							|  |  |  | [ f ] [ H{ { 1 2 } { 2 3 } } sequence-mixin? ] unit-test | 
					
						
							|  |  |  | [ t ] [ H{ { 1 2 } { 2 3 } } assoc-mixin? ] unit-test | 
					
						
							|  |  |  | [ 2 ] [ H{ { 1 2 } { 2 3 } } collection-size ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Test mixing in of new classes after the fact | 
					
						
							| 
									
										
										
										
											2008-03-24 20:52:21 -04:00
										 |  |  | DEFER: mx1 | 
					
						
							|  |  |  | FORGET: mx1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | MIXIN: mx1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | INSTANCE: integer mx1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ integer mx1 class<= ] unit-test | 
					
						
							|  |  |  | [ t ] [ mx1 integer class<= ] unit-test | 
					
						
							|  |  |  | [ t ] [ mx1 number class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | "IN: classes.tests USE: arrays INSTANCE: array mx1" eval | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ array mx1 class<= ] unit-test | 
					
						
							|  |  |  | [ f ] [ mx1 number class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-24 17:32:41 -05:00
										 |  |  | [ \ mx1 forget ] with-compilation-unit | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Empty unions were causing problems | 
					
						
							| 
									
										
										
										
											2008-06-08 16:32:55 -04:00
										 |  |  | GENERIC: empty-union-test ( obj -- obj )
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | UNION: empty-union-1 ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: empty-union-1 empty-union-test ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | UNION: empty-union-2 ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: empty-union-2 empty-union-test ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Redefining a class didn't update containing unions | 
					
						
							|  |  |  | UNION: redefine-bug-1 fixnum ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | UNION: redefine-bug-2 redefine-bug-1 quotation ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ fixnum redefine-bug-2 class<= ] unit-test | 
					
						
							|  |  |  | [ t ] [ quotation redefine-bug-2 class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | [ ] [ "IN: classes.tests USE: math UNION: redefine-bug-1 bignum ;" eval ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 03:51:38 -04:00
										 |  |  | [ t ] [ bignum redefine-bug-1 class<= ] unit-test | 
					
						
							|  |  |  | [ f ] [ fixnum redefine-bug-2 class<= ] unit-test | 
					
						
							|  |  |  | [ t ] [ bignum redefine-bug-2 class<= ] unit-test | 
					
						
							| 
									
										
										
										
											2008-01-04 21:10:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-19 16:24:49 -04:00
										 |  |  | USE: io.streams.string | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-13 18:20:28 -04:00
										 |  |  | 2 [ | 
					
						
							|  |  |  |     [ "mixin-forget-test" forget-source ] with-compilation-unit | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     [ ] [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             "USING: sequences ;" | 
					
						
							|  |  |  |             "IN: classes.tests" | 
					
						
							|  |  |  |             "MIXIN: mixin-forget-test" | 
					
						
							|  |  |  |             "INSTANCE: sequence mixin-forget-test" | 
					
						
							|  |  |  |             "GENERIC: mixin-forget-test-g ( x -- y )" | 
					
						
							|  |  |  |             "M: mixin-forget-test mixin-forget-test-g ;" | 
					
						
							|  |  |  |         } "\n" join <string-reader> "mixin-forget-test" | 
					
						
							|  |  |  |         parse-stream drop
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     [ { } ] [ { } "mixin-forget-test-g" "classes.tests" lookup execute ] unit-test | 
					
						
							|  |  |  |     [ H{ } "mixin-forget-test-g" "classes.tests" lookup execute ] must-fail | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     [ ] [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             "USING: hashtables ;" | 
					
						
							|  |  |  |             "IN: classes.tests" | 
					
						
							|  |  |  |             "MIXIN: mixin-forget-test" | 
					
						
							|  |  |  |             "INSTANCE: hashtable mixin-forget-test" | 
					
						
							|  |  |  |             "GENERIC: mixin-forget-test-g ( x -- y )" | 
					
						
							|  |  |  |             "M: mixin-forget-test mixin-forget-test-g ;" | 
					
						
							|  |  |  |         } "\n" join <string-reader> "mixin-forget-test" | 
					
						
							|  |  |  |         parse-stream drop
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     [ { } "mixin-forget-test-g" "classes.tests" lookup execute ] must-fail | 
					
						
							|  |  |  |     [ H{ } ] [ H{ } "mixin-forget-test-g" "classes.tests" lookup execute ] unit-test | 
					
						
							|  |  |  | ] times
 | 
					
						
							| 
									
										
										
										
											2008-01-29 14:58:37 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Method flattening interfered with mixin update | 
					
						
							|  |  |  | MIXIN: flat-mx-1 | 
					
						
							|  |  |  | TUPLE: flat-mx-1-1 ; INSTANCE: flat-mx-1-1 flat-mx-1 | 
					
						
							|  |  |  | TUPLE: flat-mx-1-2 ; INSTANCE: flat-mx-1-2 flat-mx-1 | 
					
						
							|  |  |  | TUPLE: flat-mx-1-3 ; INSTANCE: flat-mx-1-3 flat-mx-1 | 
					
						
							|  |  |  | TUPLE: flat-mx-1-4 ; INSTANCE: flat-mx-1-4 flat-mx-1 | 
					
						
							|  |  |  | MIXIN: flat-mx-2     INSTANCE: flat-mx-2 flat-mx-1 | 
					
						
							|  |  |  | TUPLE: flat-mx-2-1 ; INSTANCE: flat-mx-2-1 flat-mx-2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ T{ flat-mx-2-1 } flat-mx-1? ] unit-test | 
					
						
							| 
									
										
										
										
											2008-03-19 16:24:49 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Test generic see and parsing | 
					
						
							|  |  |  | [ "USING: alien math ;\nIN: classes.tests\nUNION: bah fixnum alien ;\n" ] | 
					
						
							|  |  |  | [ [ \ bah see ] with-string-writer ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-02 22:27:49 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ 3 object instance? ] unit-test | 
					
						
							|  |  |  | [ t ] [ 3 fixnum instance? ] unit-test | 
					
						
							|  |  |  | [ f ] [ 3 float instance? ] unit-test | 
					
						
							|  |  |  | [ t ] [ 3 number instance? ] unit-test | 
					
						
							|  |  |  | [ f ] [ 3 null instance? ] unit-test | 
					
						
							|  |  |  | [ t ] [ "hi" \ hi-tag instance? ] unit-test | 
					
						
							| 
									
										
										
										
											2008-05-23 18:33:57 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Regression | 
					
						
							| 
									
										
										
										
											2008-06-08 16:32:55 -04:00
										 |  |  | GENERIC: method-forget-test ( obj -- obj )
 | 
					
						
							| 
									
										
										
										
											2008-05-23 18:33:57 -04:00
										 |  |  | TUPLE: method-forget-class ;
 | 
					
						
							|  |  |  | M: method-forget-class method-forget-test ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-28 20:34:18 -04:00
										 |  |  | [ f ] [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test | 
					
						
							| 
									
										
										
										
											2008-05-23 18:33:57 -04:00
										 |  |  | [ ] [ [ \ method-forget-class forget ] with-compilation-unit ] unit-test | 
					
						
							| 
									
										
										
										
											2008-05-28 20:34:18 -04:00
										 |  |  | [ t ] [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test | 
					
						
							| 
									
										
										
										
											2008-06-12 06:49:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ | 
					
						
							|  |  |  |     all-words [ class? ] filter
 | 
					
						
							|  |  |  |     implementors-map get keys
 | 
					
						
							|  |  |  |     [ natural-sort ] bi@ =
 | 
					
						
							|  |  |  | ] unit-test |