| 
									
										
										
										
											2009-01-08 19:56:49 -05:00
										 |  |  | ! Copyright (C) 2009 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-04-22 08:05:00 -04:00
										 |  |  | USING: tools.test combinators.smart math kernel accessors ;
 | 
					
						
							| 
									
										
										
										
											2009-01-08 19:56:49 -05:00
										 |  |  | IN: combinators.smart.tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : test-bi ( -- 9 11 )
 | 
					
						
							| 
									
										
										
										
											2009-08-13 20:21:44 -04:00
										 |  |  |     10 [ 1 - ] [ 1 + ] bi ;
 | 
					
						
							| 
									
										
										
										
											2009-01-08 19:56:49 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ [ test-bi ] output>array ] must-infer | 
					
						
							|  |  |  | [ { 9 11 } ] [ [ test-bi ] output>array ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ { 9 11 } [ + ] input<sequence ] must-infer | 
					
						
							|  |  |  | [ 20 ] [ { 9 11 } [ + ] input<sequence ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-09 16:39:47 -05:00
										 |  |  | [ 6 ] [ [ 1 2 3 ] [ + ] reduce-outputs ] unit-test | 
					
						
							| 
									
										
										
										
											2009-01-08 19:56:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-09 16:39:47 -05:00
										 |  |  | [ [ 1 2 3 ] [ + ] reduce-outputs ] must-infer | 
					
						
							| 
									
										
										
										
											2009-01-08 19:56:49 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ 6 ] [ [ 1 2 3 ] sum-outputs ] unit-test | 
					
						
							| 
									
										
										
										
											2009-01-18 22:18:52 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ "ab" ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     [ "a" "b" ] "" append-outputs-as | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "" ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     [ ] "" append-outputs-as | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ { } ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     [ ] append-outputs | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ B{ 1 2 3 } ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     [ { 1 } { 2 } { 3 } ] B{ } append-outputs-as | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2009-02-06 05:38:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Test nesting | 
					
						
							|  |  |  | : nested-smart-combo-test ( -- array )
 | 
					
						
							|  |  |  |     [ [ 1 2 ] output>array [ 3 4 ] output>array ] output>array ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-20 22:15:19 -04:00
										 |  |  | \ nested-smart-combo-test def>> must-infer | 
					
						
							| 
									
										
										
										
											2009-02-06 05:38:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-12 03:19:41 -05:00
										 |  |  | [ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-13 20:21:44 -04:00
										 |  |  | [ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test |