]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/crossref/crossref-tests.factor
stomp.cli: simplify
[factor.git] / basis / compiler / crossref / crossref-tests.factor
1 USING: assocs compiler.crossref fry io kernel namespaces sequences
2 stack-checker.dependencies tools.test vocabs words ;
3 IN: compiler.crossref.tests
4
5 ! Dependencies of all words should always be satisfied unless we're
6 ! in the middle of recompiling something
7 { { } } [
8     all-words dup [ subwords ] map concat append
9     H{ } clone '[ _ dependencies-satisfied? ] reject
10 ] unit-test
11
12 : setup-crossref ( -- assoc )
13     H{
14         {
15             10
16             H{
17                 { 20 +definition+ }
18                 { 30 +conditional+ }
19                 { 40 +effect+ }
20             }
21         }
22     } clone ;
23
24 ! compiled-unxref
25 SYMBOL: kolobi
26 { f f } [
27     ! Setup a fake dependency; kolobi -> print
28     +effect+ kolobi compiled-crossref get \ print of set-at
29     kolobi { print } "dependencies" set-word-prop
30
31     ! Ensure it is being forgotten
32     kolobi compiled-unxref
33     kolobi "dependencies" word-prop
34     compiled-crossref get \ print of kolobi of
35 ] unit-test
36
37 ! dependencies-of
38 {
39     H{ { 20 +definition+ } }
40 } [
41     setup-crossref compiled-crossref [
42         10 +definition+ dependencies-of
43     ] with-variable
44 ] unit-test
45
46 {
47     H{ { 20 +definition+ } { 30 +conditional+ } }
48 } [
49     setup-crossref compiled-crossref [
50         10 +conditional+ dependencies-of
51     ] with-variable
52 ] unit-test
53
54 ! remove-xref
55 SYMBOLS: foo1 bar ;
56 {
57     H{ { foo1 H{ } } }
58 } [
59     bar { foo1 }
60     H{
61         { foo1 H{ { bar +definition+ } } }
62     } clone [ remove-xref ] keep
63 ] unit-test
64
65 ! store-dependencies
66 : setup-deps ( -- assoc )
67     H{
68         { 20 +definition+ }
69         { 30 +conditional+ }
70         { 40 +effect+ }
71         { 50 +effect+ }
72     } ;
73
74 SYMBOL: foo
75 {
76     { 40 50 20 30 }
77 } [
78     foo [ setup-deps store-dependencies ] keep "dependencies" word-prop
79     foo delete-compiled-xref
80 ] unit-test