@@ -1315,9 +1315,15 @@ defmodule CodeFragmentTest do
1315
1315
assert cc2q! ( "(fn x ->" , trailing_fragment: ":ok end)" ) ==
1316
1316
s2q! ( "(fn x -> __cursor__() end)" )
1317
1317
1318
- assert cc2q! ( "(fn x ->" , trailing_fragment: ":ok end)" ) ==
1318
+ assert cc2q! ( "(fn x ->" , trailing_fragment: "\n :ok end)" ) ==
1319
1319
s2q! ( "(fn x -> __cursor__() end)" )
1320
1320
1321
+ assert cc2q! ( "(fn x when " , trailing_fragment: "-> :ok end)" ) ==
1322
+ s2q! ( "(fn x when __cursor__() -> :ok end)" )
1323
+
1324
+ assert cc2q! ( "(fn x when " , trailing_fragment: "->\n :ok end)" ) ==
1325
+ s2q! ( "(fn x when __cursor__() -> :ok end)" )
1326
+
1321
1327
assert cc2q! ( "(fn" ) == s2q! ( "(__cursor__())" )
1322
1328
assert cc2q! ( "(fn x" ) == s2q! ( "(__cursor__())" )
1323
1329
assert cc2q! ( "(fn x," ) == s2q! ( "(__cursor__())" )
@@ -1327,6 +1333,23 @@ defmodule CodeFragmentTest do
1327
1333
assert cc2q! ( "(fn x, y -> x + y end" ) == s2q! ( "(__cursor__())" )
1328
1334
end
1329
1335
1336
+ test "do -> end" do
1337
+ assert cc2q! ( "if do\n x ->\n " , trailing_fragment: "y\n z ->\n w\n end" ) ==
1338
+ s2q! ( "if do\n x ->\n __cursor__()\n end" )
1339
+
1340
+ assert cc2q! ( "if do\n x ->\n y" , trailing_fragment: "\n z ->\n w\n end" ) ==
1341
+ s2q! ( "if do\n x ->\n __cursor__()\n end" )
1342
+
1343
+ assert cc2q! ( "if do\n x ->\n y\n " , trailing_fragment: "\n z ->\n w\n end" ) ==
1344
+ s2q! ( "if do\n x ->\n y\n __cursor__()\n end" )
1345
+
1346
+ assert cc2q! ( "for x <- [], reduce: %{} do\n y, " , trailing_fragment: "-> :ok\n end" ) ==
1347
+ s2q! ( "for x <- [], reduce: %{} do\n y, __cursor__() -> :ok\n end" )
1348
+
1349
+ assert cc2q! ( "for x <- [], reduce: %{} do\n y, z when " , trailing_fragment: "-> :ok\n end" ) ==
1350
+ s2q! ( "for x <- [], reduce: %{} do\n y, z when __cursor__() -> :ok\n end" )
1351
+ end
1352
+
1330
1353
test "removes tokens until opening" do
1331
1354
assert cc2q! ( "(123" ) == s2q! ( "(__cursor__())" )
1332
1355
assert cc2q! ( "[foo" ) == s2q! ( "[__cursor__()]" )
0 commit comments