@@ -1927,7 +1927,7 @@ defmodule SpitfireTest do
1927
1927
code = "foo $bar, baz"
1928
1928
1929
1929
assert Spitfire . parse ( code ) ==
1930
- { :error , { :foo , [ line: 1 , column: 1 ] , [ { :__error__ , [ line: 1 , column: 5 ] , [ "unknown token: %" ] } ] } ,
1930
+ { :error , { :foo , [ line: 1 , column: 1 ] , [ { :__block__ , [ error: true , line: 1 , column: 5 ] , [ ] } ] } ,
1931
1931
[ { [ line: 1 , column: 5 ] , "unknown token: %" } ] }
1932
1932
end
1933
1933
@@ -1949,9 +1949,15 @@ defmodule SpitfireTest do
1949
1949
code = "1 * (2 + 3"
1950
1950
1951
1951
assert Spitfire . parse ( code ) ==
1952
- { :error ,
1953
- { :* , [ line: 1 , column: 3 ] , [ 1 , { :__error__ , [ line: 1 , column: 10 ] , [ "missing closing parentheses" ] } ] } ,
1954
- [ { [ line: 1 , column: 10 ] , "missing closing parentheses" } ] }
1952
+ {
1953
+ :error ,
1954
+ { { :* , [ line: 1 , column: 3 ] , [ 1 , { :__block__ , [ error: true , line: 1 , column: 3 ] , [ ] } ] } ,
1955
+ [ { :closing , [ line: 1 , column: 10 ] } , { :line , 1 } , { :column , 3 } ] , [ { :+ , [ line: 1 , column: 8 ] , [ 2 , 3 ] } ] } ,
1956
+ [
1957
+ { [ line: 1 , column: 3 ] , "malformed right-hand side of * operator" } ,
1958
+ { [ line: 1 , column: 3 ] , "missing closing parentheses for function invocation" }
1959
+ ]
1960
+ }
1955
1961
end
1956
1962
1957
1963
test "missing closing list bracket" do
@@ -1968,6 +1974,13 @@ defmodule SpitfireTest do
1968
1974
1969
1975
assert Spitfire . parse ( code ) ==
1970
1976
{ :error , { :__block__ , [ ] , [ [ 1 ] , :ok ] } , [ { [ line: 1 , column: 1 ] , "missing closing bracket for list" } ] }
1977
+
1978
+ code = """
1979
+ [1, 2, 3,,
1980
+ """
1981
+
1982
+ assert Spitfire . parse ( code ) ==
1983
+ { :error , [ 1 , 2 , 3 ] , [ { [ line: 1 , column: 1 ] , "missing closing bracket for list" } ] }
1971
1984
end
1972
1985
1973
1986
test "missing closing tuple brace" do
@@ -2149,8 +2162,7 @@ defmodule SpitfireTest do
2149
2162
column: 1
2150
2163
] ,
2151
2164
[
2152
- { :+ , [ line: 1 , column: 7 ] ,
2153
- [ 1 , { :__error__ , [ line: 1 , column: 7 ] , [ "malformed right-hand side of + operator" ] } ] }
2165
+ { :+ , [ line: 1 , column: 7 ] , [ 1 , { :__block__ , [ error: true , line: 1 , column: 7 ] , [ ] } ] }
2154
2166
] } ,
2155
2167
{ :bar ,
2156
2168
[
@@ -2430,6 +2442,59 @@ defmodule SpitfireTest do
2430
2442
assert Spitfire . parse ( code ) == { :error , :no_fuel_remaining }
2431
2443
end
2432
2444
2445
+ test "doesn't drop the cursor node" do
2446
+ code =
2447
+ ~S'''
2448
+ %{state |
2449
+ foo: s
2450
+ __cursor__()
2451
+ ,
2452
+ bar: Foo.Bar.load(state.foo, state.baz)}
2453
+ '''
2454
+
2455
+ assert Spitfire . parse ( code ) ==
2456
+ { :error ,
2457
+ { :__block__ , [ ] ,
2458
+ [
2459
+ { :%{} , [ closing: [ line: 2 , column: 8 ] , line: 1 , column: 1 ] ,
2460
+ [
2461
+ { :| , [ newlines: 1 , line: 1 , column: 9 ] ,
2462
+ [
2463
+ { :state , [ line: 1 , column: 3 ] , nil } ,
2464
+ [ foo: { :s , [ line: 2 , column: 8 ] , nil } ]
2465
+ ] }
2466
+ ] } ,
2467
+ { :s , [ end_of_expression: [ newlines: 1 , line: 3 , column: 13 ] , line: 2 , column: 8 ] ,
2468
+ [ { :__cursor__ , [ closing: [ line: 3 , column: 12 ] , line: 3 , column: 1 ] , [ ] } ] } ,
2469
+ { :__block__ , [ error: true , line: 4 , column: 1 ] , [ ] } ,
2470
+ { { :. , [ line: 5 , column: 15 ] ,
2471
+ [
2472
+ { :__aliases__ , [ last: [ line: 5 , column: 12 ] , line: 5 , column: 8 ] , [ :Foo , :Bar ] } ,
2473
+ :load
2474
+ ] } , [ closing: [ line: 5 , column: 41 ] , line: 5 , column: 16 ] ,
2475
+ [
2476
+ { { :. , [ line: 5 , column: 26 ] , [ { :state , [ line: 5 , column: 21 ] , nil } , :foo ] } ,
2477
+ [ no_parens: true , line: 5 , column: 27 ] , [ ] } ,
2478
+ { { :. , [ line: 5 , column: 37 ] , [ { :state , [ line: 5 , column: 32 ] , nil } , :baz ] } ,
2479
+ [ no_parens: true , line: 5 , column: 38 ] , [ ] }
2480
+ ] } ,
2481
+ { :__block__ , [ error: true , line: 5 , column: 41 ] , [ ] } ,
2482
+ { :__block__ ,
2483
+ [
2484
+ end_of_expression: [ newlines: 1 , line: 5 , column: 43 ] ,
2485
+ error: true ,
2486
+ line: 5 ,
2487
+ column: 42
2488
+ ] , [ ] }
2489
+ ] } ,
2490
+ [
2491
+ { [ line: 2 , column: 8 ] , "missing closing brace for map" } ,
2492
+ { [ line: 4 , column: 1 ] , "unknown token: ," } ,
2493
+ { [ line: 5 , column: 41 ] , "unknown token: )" } ,
2494
+ { [ line: 5 , column: 42 ] , "unknown token: }" }
2495
+ ] }
2496
+ end
2497
+
2433
2498
test "example from github issue with list elements" do
2434
2499
code = ~S'''
2435
2500
defmodule Foo do
0 commit comments