]> gitweb.factorcode.org Git - factor.git/commitdiff
locals.parser.tests: fixing the tcs so they work 1348/head
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 9 Jun 2015 10:59:04 +0000 (12:59 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 9 Jun 2015 11:02:03 +0000 (13:02 +0200)
basis/locals/parser/parser-tests.factor

index fef17b7cd56194ee73517f29c63b4b3b3f1de005..316715f92686a06097fd630e455e41d22178ecee 100644 (file)
@@ -1,28 +1,42 @@
 USING: accessors assocs compiler.units kernel lexer locals.backend
-locals.parser parser prettyprint sequences tools.test ;
+locals.parser namespaces parser prettyprint sequences sorting
+tools.test vocabs vocabs.parser ;
 IN: locals.parser.tests
 
-SYMBOL: dobiedoo
+<<
+! ((parse-lambda))
+{
+    "V{ 99 :> kkk kkk }"
+} [
+    [
+        "locals" use-vocab
+        { "99 :> kkk kkk ;" } <lexer> [
+            H{ } clone [ \ ; parse-until ] ((parse-lambda))
+        ] with-lexer
+    ] with-compilation-unit unparse
+] unit-test
 
 ! (::)
 {
-    dobiedoo
+    "dobiedoo"
     [ 1 load-locals 1 drop-locals ]
     ( x -- y )
 } [
     [
         { "dobiedoo ( x -- y ) ;" } <lexer> [ (::) ] with-lexer
     ] with-compilation-unit
+    [ name>> ] 2dip
 ] unit-test
 
-! ((parse-lambda))
-{
-    "V{ 99 :> kkk kkk }"
-} [
-    [ { "99 :> kkk kkk ;" } <lexer> [
-        H{ } clone [ \ ; parse-until ] ((parse-lambda)) ] with-lexer
-    ] with-compilation-unit unparse
+! parse-def
+{ "um" t } [
+    [
+        "um" parse-def
+        local>> name>>
+        manifest get qualified-vocabs>> last words>> keys "um" swap member?
+    ] with-compilation-unit
 ] unit-test
+>>
 
 ! check-local-name
 { "hello" } [
@@ -35,12 +49,6 @@ SYMBOL: dobiedoo
     nip values [ name>> ] map
 ] unit-test
 
-! parse-def
-{ "um" { "um" } } [
-    [ "um" H{ } clone [ parse-def ] keep ] with-compilation-unit
-    [ local>> name>> ] [ keys ] bi*
-] unit-test
-
 ! parse-local-defs
 { { "tok1" "tok2" } } [
     [
@@ -51,13 +59,11 @@ SYMBOL: dobiedoo
 
 ! parse-multi-def
 {
-    { "v1" "tok1" "tok2" }
+    { "tok1" "tok2" }
     { "tok1" "tok2" }
 } [
     [
-        { "tok1 tok2 )" } <lexer> [
-            H{ { "v1" t } } clone dup parse-multi-def
-        ] with-lexer
+        { "tok1 tok2 )" } <lexer> [ parse-multi-def ] with-lexer
     ] with-compilation-unit
-    [ keys ] [ locals>> [ name>> ] map ] bi*
+    [ locals>> [ name>> ] map ] [ keys ] bi*
 ] unit-test