]> gitweb.factorcode.org Git - factor.git/blob - core/locals/parser/parser-tests.factor
core: whoops, all these moves got missed.
[factor.git] / core / locals / parser / parser-tests.factor
1 USING: accessors assocs compiler.units kernel lexer locals.backend
2 locals.parser namespaces parser prettyprint sequences sorting
3 tools.test vocabs vocabs.parser ;
4 IN: locals.parser.tests
5
6 ! XXX: remove the << and >> below and make test-all pass
7
8 <<
9 ! (::)
10 {
11     "dobiedoo"
12     [ 1 load-locals 1 drop-locals ]
13     ( x -- y )
14 } [
15     [
16         { "dobiedoo ( x -- y ) ;" } <lexer> [ (::) ] with-lexer
17     ] with-compilation-unit
18     [ name>> ] 2dip
19 ] unit-test
20
21 ! parse-def
22 { "um" t } [
23     [
24         "um" parse-def
25         local>> name>>
26         qualified-vocabs last words>> keys "um" swap member?
27     ] with-compilation-unit
28 ] unit-test
29 >>
30
31 ! check-local-name
32 { "hello" } [
33     "hello" check-local-name
34 ] unit-test
35
36 ! make-locals
37 { { "a" "b" "c" } } [
38     [ { "a" "b" "c" } make-locals ] with-compilation-unit
39     nip values [ name>> ] map
40 ] unit-test
41
42 ! parse-local-defs
43 { { "tok1" "tok2" } } [
44     [
45         { "tok1 tok2 |" } <lexer> [ parse-local-defs ] with-lexer
46     ] with-compilation-unit
47     nip values [ name>> ] map
48 ] unit-test
49
50 ! parse-multi-def
51 {
52     { "tok1" "tok2" }
53     { "tok1" "tok2" }
54 } [
55     [
56         { "tok1 tok2 )" } <lexer> [ parse-multi-def ] with-lexer
57     ] with-compilation-unit
58     [ locals>> [ name>> ] map ] [ keys ] bi*
59 ] unit-test
60
61 <<
62 {
63     "V{ 99 :> kkk kkk }"
64 } [
65     [
66         "locals" use-vocab
67         { "99 :> kkk kkk ;" } <lexer> [
68             H{ } clone [ \ ; parse-until ] with-lambda-scope
69         ] with-lexer
70     ] with-compilation-unit unparse
71 ] unit-test
72 >>