|
1 | 1 | @testset "Hooks for Core integration" begin
|
2 |
| - JuliaSyntax.enable_in_core!() |
| 2 | + @testset "filename is used" begin |
| 3 | + ex = JuliaSyntax.core_parser_hook("@a", "somefile", 0, :statement)[1] |
| 4 | + @test Meta.isexpr(ex, :macrocall) |
| 5 | + @test ex.args[2] == LineNumberNode(1, "somefile") |
| 6 | + end |
3 | 7 |
|
4 |
| - @test Meta.parse("x + 1") == :(x + 1) |
5 |
| - @test Meta.parse("x + 1", 1) == (:(x + 1), 6) |
| 8 | + @testset "enable_in_core!" begin |
| 9 | + JuliaSyntax.enable_in_core!() |
6 | 10 |
|
7 |
| - # Test that parsing statements incrementally works and stops after |
8 |
| - # whitespace / comment trivia |
9 |
| - @test Meta.parse("x + 1\n(y)\n", 1) == (:(x + 1), 7) |
10 |
| - @test Meta.parse("x + 1\n(y)\n", 7) == (:y, 11) |
11 |
| - @test Meta.parse(" x#==#", 1) == (:x, 7) |
| 11 | + @test Meta.parse("x + 1") == :(x + 1) |
| 12 | + @test Meta.parse("x + 1", 1) == (:(x + 1), 6) |
12 | 13 |
|
13 |
| - # Check that Meta.parse throws the JuliaSyntax.ParseError rather than |
14 |
| - # Meta.ParseError when Core integration is enabled. |
15 |
| - @test_throws JuliaSyntax.ParseError Meta.parse("[x") |
| 14 | + # Test that parsing statements incrementally works and stops after |
| 15 | + # whitespace / comment trivia |
| 16 | + @test Meta.parse("x + 1\n(y)\n", 1) == (:(x + 1), 7) |
| 17 | + @test Meta.parse("x + 1\n(y)\n", 7) == (:y, 11) |
| 18 | + @test Meta.parse(" x#==#", 1) == (:x, 7) |
16 | 19 |
|
17 |
| - JuliaSyntax.enable_in_core!(false) |
| 20 | + # Check that Meta.parse throws the JuliaSyntax.ParseError rather than |
| 21 | + # Meta.ParseError when Core integration is enabled. |
| 22 | + @test_throws JuliaSyntax.ParseError Meta.parse("[x") |
| 23 | + |
| 24 | + JuliaSyntax.enable_in_core!(false) |
| 25 | + end |
18 | 26 | end
|
0 commit comments