|
1 | | -function test_parse(production, code; v=v"1.6") |
| 1 | +function test_parse(production, code; v=v"1.6", expr=false) |
2 | 2 | stream = ParseStream(code, version=v) |
3 | 3 | production(ParseState(stream)) |
4 | 4 | t = build_tree(GreenNode, stream, wrap_toplevel_as_kind=K"None") |
5 | 5 | source = SourceFile(code) |
6 | 6 | s = SyntaxNode(source, t) |
7 | | - if kind(s) == K"None" |
8 | | - join([sprint(show, MIME("text/x.sexpression"), c) for c in children(s)], ' ') |
| 7 | + if expr |
| 8 | + JuliaSyntax.remove_linenums!(Expr(s)) |
9 | 9 | else |
10 | | - sprint(show, MIME("text/x.sexpression"), s) |
| 10 | + if kind(s) == K"None" |
| 11 | + join([sprint(show, MIME("text/x.sexpression"), c) for c in children(s)], ' ') |
| 12 | + else |
| 13 | + sprint(show, MIME("text/x.sexpression"), s) |
| 14 | + end |
11 | 15 | end |
12 | 16 | end |
13 | 17 |
|
@@ -482,7 +486,8 @@ tests = [ |
482 | 486 | ((v=v"1.8",), "try else end") => "(try (block) false false (error (block)) false)" |
483 | 487 | ((v=v"1.7",), "try catch ; else end") => "(try (block) false (block) (error (block)) false)" |
484 | 488 | # finally before catch :-( |
485 | | - "try x finally y catch e z end" => "(try-f (block x) false false false (block y) e (block z))" |
| 489 | + "try x finally y catch e z end" => "(try_finally_catch (block x) false false false (block y) e (block z))" => |
| 490 | + Expr(:try, Expr(:block, :x), :e, Expr(:block, :z), Expr(:block, :y)) |
486 | 491 | ], |
487 | 492 | JuliaSyntax.parse_imports => [ |
488 | 493 | "import A as B: x" => "(import (: (error (as (. A) B)) (. x)))" |
@@ -816,7 +821,12 @@ broken_tests = [ |
816 | 821 | else |
817 | 822 | opts = NamedTuple() |
818 | 823 | end |
819 | | - @test test_parse(production, input; opts...) == output |
| 824 | + if output isa Pair |
| 825 | + @test test_parse(production, input; opts...) == output[1] |
| 826 | + @test test_parse(production, input; opts..., expr=true) == output[2] |
| 827 | + else |
| 828 | + @test test_parse(production, input; opts...) == output |
| 829 | + end |
820 | 830 | end |
821 | 831 | end |
822 | 832 | @testset "Broken $production" for (production, test_specs) in broken_tests |
|
0 commit comments