locals.parser.tests: fixing the tcs so they work

db4
Björn Lindqvist 2015-06-09 12:59:04 +02:00
parent 92868fe778
commit c2290aa141
1 changed files with 27 additions and 21 deletions

View File

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