| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | USING: delegate kernel arrays tools.test words math definitions | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | compiler.units parser generic prettyprint io.streams.string | 
					
						
							| 
									
										
										
										
											2008-07-29 01:05:01 -04:00
										 |  |  | accessors eval ;
 | 
					
						
							| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: delegate.tests | 
					
						
							| 
									
										
										
										
											2007-11-28 10:49:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | TUPLE: hello this that ;
 | 
					
						
							|  |  |  | C: <hello> hello | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: goodbye these those ;
 | 
					
						
							|  |  |  | C: <goodbye> goodbye | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GENERIC: foo ( x -- y )
 | 
					
						
							|  |  |  | GENERIC: bar ( a -- b )
 | 
					
						
							| 
									
										
										
										
											2008-04-05 03:44:54 -04:00
										 |  |  | GENERIC# whoa 1 ( s t -- w )
 | 
					
						
							|  |  |  | PROTOCOL: baz foo { bar 0 } { whoa 1 } ;
 | 
					
						
							| 
									
										
										
										
											2007-11-28 10:49:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | : hello-test ( hello/goodbye -- array )
 | 
					
						
							|  |  |  |     [ hello? ] [ hello-this ] [ hello-that ] tri 3array ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | CONSULT: baz goodbye these>> ;
 | 
					
						
							|  |  |  | M: hello foo this>> ;
 | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | M: hello bar hello-test ;
 | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | M: hello whoa >r this>> r> + ;
 | 
					
						
							| 
									
										
										
										
											2007-11-28 10:49:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | GENERIC: bing ( c -- d )
 | 
					
						
							| 
									
										
										
										
											2008-04-05 03:44:54 -04:00
										 |  |  | PROTOCOL: bee bing ;
 | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | CONSULT: hello goodbye those>> ;
 | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | M: hello bing hello-test ;
 | 
					
						
							| 
									
										
										
										
											2007-11-28 10:49:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | [ 1 { t 1 0 } ] [ 1 0 <hello> [ foo ] [ bar ] bi ] unit-test | 
					
						
							|  |  |  | [ { t 1 0 } ] [ 1 0 <hello> bing ] unit-test | 
					
						
							| 
									
										
										
										
											2007-11-28 10:49:43 -05:00
										 |  |  | [ 1 ] [ 1 0 <hello> f <goodbye> foo ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | [ { t 1 0 } ] [ 1 0 <hello> f <goodbye> bar ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-05 03:44:54 -04:00
										 |  |  | [ 3 ] [ 1 0 <hello> 2 whoa ] unit-test | 
					
						
							|  |  |  | [ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | [ ] [ 3 [ "USE: delegate IN: delegate.tests CONSULT: baz goodbye goodbye-these ;" eval ] times ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-17 23:39:25 -04:00
										 |  |  | [ H{ { goodbye [ goodbye-these ] } } ] [ baz protocol-consult ] unit-test | 
					
						
							|  |  |  | [ H{ } ] [ bee protocol-consult ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-18 00:20:17 -04:00
										 |  |  | [ "USING: delegate ;\nIN: delegate.tests\nPROTOCOL: baz foo bar { whoa 1 } ;\n" ] [ [ baz see ] with-string-writer ] unit-test | 
					
						
							| 
									
										
										
										
											2008-04-05 00:14:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-10 01:16:46 -04:00
										 |  |  | GENERIC: one | 
					
						
							|  |  |  | M: integer one ;
 | 
					
						
							|  |  |  | GENERIC: two | 
					
						
							|  |  |  | M: integer two ;
 | 
					
						
							|  |  |  | GENERIC: three | 
					
						
							|  |  |  | M: integer three ;
 | 
					
						
							|  |  |  | GENERIC: four | 
					
						
							|  |  |  | M: integer four ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PROTOCOL: alpha one two ;
 | 
					
						
							|  |  |  | PROTOCOL: beta three ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: hey value ;
 | 
					
						
							|  |  |  | C: <hey> hey | 
					
						
							|  |  |  | CONSULT: alpha hey value>> 1+ ;
 | 
					
						
							|  |  |  | CONSULT: beta hey value>> 1- ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 2 ] [ 1 <hey> one ] unit-test | 
					
						
							|  |  |  | [ 2 ] [ 1 <hey> two ] unit-test | 
					
						
							|  |  |  | [ 0 ] [ 1 <hey> three ] unit-test | 
					
						
							|  |  |  | [ { hey } ] [ alpha protocol-users ] unit-test | 
					
						
							|  |  |  | [ { hey } ] [ beta protocol-users ] unit-test | 
					
						
							|  |  |  | [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: alpha one ;" eval ] unit-test | 
					
						
							|  |  |  | [ f ] [ hey \ two method ] unit-test | 
					
						
							|  |  |  | [ f ] [ hey \ four method ] unit-test | 
					
						
							|  |  |  | [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: beta two three four ;" eval ] unit-test | 
					
						
							|  |  |  | [ { hey } ] [ alpha protocol-users ] unit-test | 
					
						
							|  |  |  | [ { hey } ] [ beta protocol-users ] unit-test | 
					
						
							|  |  |  | [ 2 ] [ 1 <hey> one ] unit-test | 
					
						
							|  |  |  | [ 0 ] [ 1 <hey> two ] unit-test | 
					
						
							|  |  |  | [ 0 ] [ 1 <hey> three ] unit-test | 
					
						
							|  |  |  | [ 0 ] [ 1 <hey> four ] unit-test | 
					
						
							|  |  |  | [ ] [ "USING: math accessors delegate ; IN: delegate.tests CONSULT: beta hey value>> 2 - ;" eval ] unit-test | 
					
						
							|  |  |  | [ 2 ] [ 1 <hey> one ] unit-test | 
					
						
							|  |  |  | [ -1 ] [ 1 <hey> two ] unit-test | 
					
						
							|  |  |  | [ -1 ] [ 1 <hey> three ] unit-test | 
					
						
							|  |  |  | [ -1 ] [ 1 <hey> four ] unit-test | 
					
						
							|  |  |  | [ ] [ "IN: delegate.tests FORGET: alpha" eval ] unit-test | 
					
						
							|  |  |  | [ f ] [ hey \ one method ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-14 14:37:24 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | TUPLE: slot-protocol-test-1 a b ;
 | 
					
						
							|  |  |  | TUPLE: slot-protocol-test-2 < slot-protocol-test-1 { c integer } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: slot-protocol-test-3 d ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CONSULT: slot-protocol-test-2 slot-protocol-test-3 d>> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "a" "b" 5 ] [ | 
					
						
							|  |  |  |     T{ slot-protocol-test-3 f T{ slot-protocol-test-2 f "a" "b" 5 } } | 
					
						
							|  |  |  |     [ a>> ] [ b>> ] [ c>> ] tri
 | 
					
						
							|  |  |  | ] unit-test |