| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  | USING: assocs compiler.crossref fry io kernel namespaces sequences | 
					
						
							|  |  |  | stack-checker.dependencies tools.test vocabs words ;
 | 
					
						
							| 
									
										
										
										
											2010-02-19 18:01:47 -05:00
										 |  |  | IN: compiler.crossref.tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Dependencies of all words should always be satisfied unless we're | 
					
						
							|  |  |  | ! in the middle of recompiling something | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { { } } [ | 
					
						
							| 
									
										
										
										
											2010-02-19 18:01:47 -05:00
										 |  |  |     all-words dup [ subwords ] map concat append
 | 
					
						
							| 
									
										
										
										
											2015-05-12 21:50:34 -04:00
										 |  |  |     H{ } clone '[ _ dependencies-satisfied? ] reject | 
					
						
							| 
									
										
										
										
											2010-02-19 18:01:47 -05:00
										 |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : setup-crossref ( -- assoc )
 | 
					
						
							|  |  |  |     H{ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             10
 | 
					
						
							|  |  |  |             H{ | 
					
						
							| 
									
										
										
										
											2016-11-26 09:44:09 -05:00
										 |  |  |                 { 20 +definition+ } | 
					
						
							|  |  |  |                 { 30 +conditional+ } | 
					
						
							|  |  |  |                 { 40 +effect+ } | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } clone ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  | ! compiled-unxref | 
					
						
							|  |  |  | SYMBOL: kolobi | 
					
						
							|  |  |  | { f f } [ | 
					
						
							|  |  |  |     ! Setup a fake dependency; kolobi -> print | 
					
						
							|  |  |  |     +effect+ kolobi compiled-crossref get \ print of set-at
 | 
					
						
							|  |  |  |     kolobi { print } "dependencies" set-word-prop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! Ensure it is being forgotten | 
					
						
							|  |  |  |     kolobi compiled-unxref | 
					
						
							|  |  |  |     kolobi "dependencies" word-prop | 
					
						
							|  |  |  |     compiled-crossref get \ print of kolobi of
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | ! dependencies-of | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-11-26 09:44:09 -05:00
										 |  |  |     H{ { 20 +definition+ } } | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | } [ | 
					
						
							|  |  |  |     setup-crossref compiled-crossref [ | 
					
						
							| 
									
										
										
										
											2016-11-26 09:44:09 -05:00
										 |  |  |         10 +definition+ dependencies-of | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  |     ] with-variable
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-11-26 09:44:09 -05:00
										 |  |  |     H{ { 20 +definition+ } { 30 +conditional+ } } | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | } [ | 
					
						
							|  |  |  |     setup-crossref compiled-crossref [ | 
					
						
							| 
									
										
										
										
											2016-11-26 09:44:09 -05:00
										 |  |  |         10 +conditional+ dependencies-of | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  |     ] with-variable
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  | ! remove-xref | 
					
						
							|  |  |  | SYMBOLS: foo1 bar ;
 | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  |     H{ { foo1 H{ } } } | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | } [ | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  |     bar { foo1 } | 
					
						
							|  |  |  |     H{ | 
					
						
							|  |  |  |         { foo1 H{ { bar +definition+ } } } | 
					
						
							|  |  |  |     } clone [ remove-xref ] keep
 | 
					
						
							| 
									
										
										
										
											2016-11-26 06:58:09 -05:00
										 |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2016-11-27 22:13:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! store-dependencies | 
					
						
							|  |  |  | : setup-deps ( -- assoc )
 | 
					
						
							|  |  |  |     H{ | 
					
						
							|  |  |  |         { 20 +definition+ } | 
					
						
							|  |  |  |         { 30 +conditional+ } | 
					
						
							|  |  |  |         { 40 +effect+ } | 
					
						
							|  |  |  |         { 50 +effect+ } | 
					
						
							|  |  |  |     } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SYMBOL: foo | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  |     { 40 50 20 30 } | 
					
						
							| 
									
										
										
										
											2016-11-27 22:13:58 -05:00
										 |  |  | } [ | 
					
						
							| 
									
										
										
										
											2016-11-28 00:33:58 -05:00
										 |  |  |     foo [ setup-deps store-dependencies ] keep "dependencies" word-prop | 
					
						
							|  |  |  |     foo delete-compiled-xref | 
					
						
							| 
									
										
										
										
											2016-11-27 22:13:58 -05:00
										 |  |  | ] unit-test |