<commit_before>USING: accessors assocs compiler.units kernel lexer locals.backend
locals.parser namespaces parser prettyprint sequences sorting
tools.test vocabs vocabs.parser ;
IN: locals.parser.tests

! XXX: remove the << and >> below and make test-all pass

<<
! (::)
{
    "dobiedoo"
    [ 1 load-locals 1 drop-locals ]
    ( x -- y )
} [
    [
        { "dobiedoo ( x -- y ) ;" } <lexer> [ (::) ] with-lexer
    ] with-compilation-unit
    [ name>> ] 2dip
] unit-test

! parse-def
{ "um" t } [
    [
        "um" parse-def
        local>> name>>
        qualified-vocabs last words>> keys "um" swap member?
    ] with-compilation-unit
] unit-test
>>

! check-local-name
{ "hello" } [
    "hello" check-local-name
] unit-test

! make-locals
{ { "a" "b" "c" } } [
    [ { "a" "b" "c" } make-locals ] with-compilation-unit
    nip values [ name>> ] map
] unit-test

! parse-local-defs
{ { "tok1" "tok2" } } [
    [
        { "tok1 tok2 |" } <lexer> [ parse-local-defs ] with-lexer
    ] with-compilation-unit
    nip values [ name>> ] map
] unit-test

! parse-multi-def
{
    { "tok1" "tok2" }
    { "tok1" "tok2" }
} [
    [
        { "tok1 tok2 )" } <lexer> [ parse-multi-def ] with-lexer
    ] with-compilation-unit
    [ locals>> [ name>> ] map ] [ keys ] bi*
] unit-test

<<
{
    "V{ 99 :> kkk kkk }"
} [
    [
        "locals" use-vocab
        { "99 :> kkk kkk ;" } <lexer> [
            H{ } clone [ \ ; parse-until ] with-lambda-scope
        ] with-lexer
    ] with-compilation-unit unparse
] unit-test
>><commit_msg>locals.parser: remove << >> from tests to see if it works now.<commit_after>USING: accessors assocs compiler.units kernel lexer
locals.backend locals.parser parser prettyprint sequences
tools.test vocabs.parser ;

! (::)
{
    "dobiedoo"
    [ 1 load-locals 1 drop-locals ]
    ( x -- y )
} [
    [
        { "dobiedoo ( x -- y ) ;" } <lexer> [ (::) ] with-lexer
    ] with-compilation-unit
    [ name>> ] 2dip
] unit-test

! parse-def
{ "um" t } [
    [
        "um" parse-def
        local>> name>>
        qualified-vocabs last words>> keys "um" swap member?
    ] with-compilation-unit
] unit-test

! check-local-name
{ "hello" } [
    "hello" check-local-name
] unit-test

! make-locals
{ { "a" "b" "c" } } [
    [ { "a" "b" "c" } make-locals ] with-compilation-unit
    nip values [ name>> ] map
] unit-test

! parse-local-defs
{ { "tok1" "tok2" } } [
    [
        { "tok1 tok2 |" } <lexer> [ parse-local-defs ] with-lexer
    ] with-compilation-unit
    nip values [ name>> ] map
] unit-test

! parse-multi-def
{
    { "tok1" "tok2" }
    { "tok1" "tok2" }
} [
    [
        { "tok1 tok2 )" } <lexer> [ parse-multi-def ] with-lexer
    ] with-compilation-unit
    [ locals>> [ name>> ] map ] [ keys ] bi*
] unit-test

{
    "V{ 99 :> kkk kkk }"
} [
    [
        { "99 :> kkk kkk ;" } <lexer> [
            H{ } clone [ \ ; parse-until ] with-lambda-scope
        ] with-lexer
    ] with-compilation-unit unparse
] unit-test
{'fraction_non_alphanumeric': 0.174881836596894, 'fraction_numerical': 0.011478730587440918, 'mean_word_length': 2.1655982905982905, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1871518', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1150, 'n_words': 247}