@@ -428,49 +428,50 @@ defmodule CodeFragmentTest do
428
428
end
429
429
430
430
test "column out of range" do
431
- assert CF . surround_context ( "hello" , { 1 , 20 } ) == :none
431
+ assert CF . surround_context ( "hello" , { 1 , 20 } ) ==
432
+ % { begin: { 1 , 1 } , context: { :local_or_var , ~c" hello" } , end: { 1 , 6 } }
432
433
end
433
434
434
435
test "local_or_var" do
435
- for i <- 1 .. 8 do
436
+ for i <- 1 .. 9 do
436
437
assert CF . surround_context ( "hello_wo" , { 1 , i } ) == % {
437
438
context: { :local_or_var , ~c" hello_wo" } ,
438
439
begin: { 1 , 1 } ,
439
440
end: { 1 , 9 }
440
441
}
441
442
end
442
443
443
- assert CF . surround_context ( "hello_wo" , { 1 , 9 } ) == :none
444
+ assert CF . surround_context ( "hello_wo " , { 1 , 10 } ) == :none
444
445
445
- for i <- 2 .. 9 do
446
+ for i <- 2 .. 10 do
446
447
assert CF . surround_context ( " hello_wo" , { 1 , i } ) == % {
447
448
context: { :local_or_var , ~c" hello_wo" } ,
448
449
begin: { 1 , 2 } ,
449
450
end: { 1 , 10 }
450
451
}
451
452
end
452
453
453
- assert CF . surround_context ( " hello_wo" , { 1 , 10 } ) == :none
454
+ assert CF . surround_context ( " hello_wo " , { 1 , 11 } ) == :none
454
455
455
- for i <- 1 .. 6 do
456
+ for i <- 1 .. 7 do
456
457
assert CF . surround_context ( "hello!" , { 1 , i } ) == % {
457
458
context: { :local_or_var , ~c" hello!" } ,
458
459
begin: { 1 , 1 } ,
459
460
end: { 1 , 7 }
460
461
}
461
462
end
462
463
463
- assert CF . surround_context ( "hello!" , { 1 , 7 } ) == :none
464
+ assert CF . surround_context ( "hello! " , { 1 , 8 } ) == :none
464
465
465
- for i <- 1 .. 5 do
466
+ for i <- 1 .. 6 do
466
467
assert CF . surround_context ( "안녕_세상" , { 1 , i } ) == % {
467
468
context: { :local_or_var , ~c" 안녕_세상" } ,
468
469
begin: { 1 , 1 } ,
469
470
end: { 1 , 6 }
470
471
}
471
472
end
472
473
473
- assert CF . surround_context ( "안녕_세상" , { 1 , 6 } ) == :none
474
+ assert CF . surround_context ( "안녕_세상 " , { 1 , 6 } ) == :none
474
475
475
476
# Keywords are not local or var
476
477
for keyword <- ~w( do end after catch else rescue fn true false nil) c do
@@ -484,46 +485,77 @@ defmodule CodeFragmentTest do
484
485
end
485
486
end
486
487
487
- test "local call " do
488
+ test "local + operator " do
488
489
for i <- 1 .. 8 do
490
+ assert CF . surround_context ( "hello_wo+" , { 1 , i } ) == % {
491
+ context: { :local_or_var , ~c" hello_wo" } ,
492
+ begin: { 1 , 1 } ,
493
+ end: { 1 , 9 }
494
+ }
495
+ end
496
+
497
+ assert CF . surround_context ( "hello_wo+" , { 1 , 9 } ) == % {
498
+ begin: { 1 , 9 } ,
499
+ context: { :operator , ~c" +" } ,
500
+ end: { 1 , 10 }
501
+ }
502
+
503
+ for i <- 1 .. 9 do
504
+ assert CF . surround_context ( "hello_wo +" , { 1 , i } ) == % {
505
+ context: { :local_or_var , ~c" hello_wo" } ,
506
+ begin: { 1 , 1 } ,
507
+ end: { 1 , 9 }
508
+ }
509
+ end
510
+
511
+ assert CF . surround_context ( "hello_wo +" , { 1 , 10 } ) == % {
512
+ begin: { 1 , 10 } ,
513
+ context: { :operator , ~c" +" } ,
514
+ end: { 1 , 11 }
515
+ }
516
+ end
517
+
518
+ test "local call" do
519
+ for i <- 1 .. 9 do
489
520
assert CF . surround_context ( "hello_wo(" , { 1 , i } ) == % {
490
521
context: { :local_call , ~c" hello_wo" } ,
491
522
begin: { 1 , 1 } ,
492
523
end: { 1 , 9 }
493
524
}
494
525
end
495
526
496
- assert CF . surround_context ( "hello_wo(" , { 1 , 9 } ) == :none
527
+ assert CF . surround_context ( "hello_wo(" , { 1 , 10 } ) == :none
497
528
498
- for i <- 1 .. 8 do
529
+ for i <- 1 .. 9 do
499
530
assert CF . surround_context ( "hello_wo (" , { 1 , i } ) == % {
500
531
context: { :local_call , ~c" hello_wo" } ,
501
532
begin: { 1 , 1 } ,
502
533
end: { 1 , 9 }
503
534
}
504
535
end
505
536
506
- assert CF . surround_context ( "hello_wo (" , { 1 , 9 } ) == :none
537
+ assert CF . surround_context ( "hello_wo (" , { 1 , 10 } ) == :none
538
+ assert CF . surround_context ( "hello_wo (" , { 1 , 11 } ) == :none
507
539
508
- for i <- 1 .. 6 do
540
+ for i <- 1 .. 7 do
509
541
assert CF . surround_context ( "hello!(" , { 1 , i } ) == % {
510
542
context: { :local_call , ~c" hello!" } ,
511
543
begin: { 1 , 1 } ,
512
544
end: { 1 , 7 }
513
545
}
514
546
end
515
547
516
- assert CF . surround_context ( "hello!(" , { 1 , 7 } ) == :none
548
+ assert CF . surround_context ( "hello!(" , { 1 , 8 } ) == :none
517
549
518
- for i <- 1 .. 5 do
550
+ for i <- 1 .. 6 do
519
551
assert CF . surround_context ( "안녕_세상(" , { 1 , i } ) == % {
520
552
context: { :local_call , ~c" 안녕_세상" } ,
521
553
begin: { 1 , 1 } ,
522
554
end: { 1 , 6 }
523
555
}
524
556
end
525
557
526
- assert CF . surround_context ( "안녕_세상(" , { 1 , 6 } ) == :none
558
+ assert CF . surround_context ( "안녕_세상(" , { 1 , 7 } ) == :none
527
559
end
528
560
529
561
test "local arity" do
@@ -651,47 +683,47 @@ defmodule CodeFragmentTest do
651
683
end
652
684
653
685
test "alias" do
654
- for i <- 1 .. 8 do
686
+ for i <- 1 .. 9 do
655
687
assert CF . surround_context ( "HelloWor" , { 1 , i } ) == % {
656
688
context: { :alias , ~c" HelloWor" } ,
657
689
begin: { 1 , 1 } ,
658
690
end: { 1 , 9 }
659
691
}
660
692
end
661
693
662
- assert CF . surround_context ( "HelloWor" , { 1 , 9 } ) == :none
694
+ assert CF . surround_context ( "HelloWor " , { 1 , 10 } ) == :none
663
695
664
- for i <- 2 .. 9 do
696
+ for i <- 2 .. 10 do
665
697
assert CF . surround_context ( " HelloWor" , { 1 , i } ) == % {
666
698
context: { :alias , ~c" HelloWor" } ,
667
699
begin: { 1 , 2 } ,
668
700
end: { 1 , 10 }
669
701
}
670
702
end
671
703
672
- assert CF . surround_context ( " HelloWor" , { 1 , 10 } ) == :none
704
+ assert CF . surround_context ( " HelloWor " , { 1 , 11 } ) == :none
673
705
674
- for i <- 1 .. 9 do
706
+ for i <- 1 .. 10 do
675
707
assert CF . surround_context ( "Hello.Wor" , { 1 , i } ) == % {
676
708
context: { :alias , ~c" Hello.Wor" } ,
677
709
begin: { 1 , 1 } ,
678
710
end: { 1 , 10 }
679
711
}
680
712
end
681
713
682
- assert CF . surround_context ( "Hello.Wor" , { 1 , 10 } ) == :none
714
+ assert CF . surround_context ( "Hello.Wor " , { 1 , 11 } ) == :none
683
715
684
- for i <- 1 .. 11 do
716
+ for i <- 1 .. 12 do
685
717
assert CF . surround_context ( "Hello . Wor" , { 1 , i } ) == % {
686
718
context: { :alias , ~c" Hello.Wor" } ,
687
719
begin: { 1 , 1 } ,
688
720
end: { 1 , 12 }
689
721
}
690
722
end
691
723
692
- assert CF . surround_context ( "Hello . Wor" , { 1 , 12 } ) == :none
724
+ assert CF . surround_context ( "Hello . Wor " , { 1 , 13 } ) == :none
693
725
694
- for i <- 1 .. 15 do
726
+ for i <- 1 .. 16 do
695
727
assert CF . surround_context ( "Foo . Bar . Baz" , { 1 , i } ) == % {
696
728
context: { :alias , ~c" Foo.Bar.Baz" } ,
697
729
begin: { 1 , 1 } ,
@@ -858,15 +890,15 @@ defmodule CodeFragmentTest do
858
890
end: { 1 , 15 }
859
891
}
860
892
861
- for i <- 2 .. 9 do
893
+ for i <- 2 .. 10 do
862
894
assert CF . surround_context ( "%HelloWor" , { 1 , i } ) == % {
863
895
context: { :struct , ~c" HelloWor" } ,
864
896
begin: { 1 , 1 } ,
865
897
end: { 1 , 10 }
866
898
}
867
899
end
868
900
869
- assert CF . surround_context ( "%HelloWor" , { 1 , 10 } ) == :none
901
+ assert CF . surround_context ( "%HelloWor " , { 1 , 11 } ) == :none
870
902
871
903
# With dot
872
904
assert CF . surround_context ( "%Hello.Wor" , { 1 , 1 } ) == % {
@@ -875,15 +907,15 @@ defmodule CodeFragmentTest do
875
907
end: { 1 , 11 }
876
908
}
877
909
878
- for i <- 2 .. 10 do
910
+ for i <- 2 .. 11 do
879
911
assert CF . surround_context ( "%Hello.Wor" , { 1 , i } ) == % {
880
912
context: { :struct , ~c" Hello.Wor" } ,
881
913
begin: { 1 , 1 } ,
882
914
end: { 1 , 11 }
883
915
}
884
916
end
885
917
886
- assert CF . surround_context ( "%Hello.Wor" , { 1 , 11 } ) == :none
918
+ assert CF . surround_context ( "%Hello.Wor " , { 1 , 12 } ) == :none
887
919
888
920
# With spaces
889
921
assert CF . surround_context ( "% Hello . Wor" , { 1 , 1 } ) == % {
@@ -892,15 +924,15 @@ defmodule CodeFragmentTest do
892
924
end: { 1 , 14 }
893
925
}
894
926
895
- for i <- 2 .. 13 do
927
+ for i <- 2 .. 14 do
896
928
assert CF . surround_context ( "% Hello . Wor" , { 1 , i } ) == % {
897
929
context: { :struct , ~c" Hello.Wor" } ,
898
930
begin: { 1 , 1 } ,
899
931
end: { 1 , 14 }
900
932
}
901
933
end
902
934
903
- assert CF . surround_context ( "% Hello . Wor" , { 1 , 14 } ) == :none
935
+ assert CF . surround_context ( "% Hello . Wor " , { 1 , 15 } ) == :none
904
936
end
905
937
906
938
test "module attributes" do
0 commit comments