@@ -443,50 +443,49 @@ defmodule CodeFragmentTest do
443
443
end
444
444
445
445
test "column out of range" do
446
- assert CF . surround_context ( "hello" , { 1 , 20 } ) ==
447
- % { begin: { 1 , 1 } , context: { :local_or_var , ~c" hello" } , end: { 1 , 6 } }
446
+ assert CF . surround_context ( "hello" , { 1 , 20 } ) == :none
448
447
end
449
448
450
449
test "local_or_var" do
451
- for i <- 1 .. 9 do
450
+ for i <- 1 .. 8 do
452
451
assert CF . surround_context ( "hello_wo" , { 1 , i } ) == % {
453
452
context: { :local_or_var , ~c" hello_wo" } ,
454
453
begin: { 1 , 1 } ,
455
454
end: { 1 , 9 }
456
455
}
457
456
end
458
457
459
- assert CF . surround_context ( "hello_wo " , { 1 , 10 } ) == :none
458
+ assert CF . surround_context ( "hello_wo" , { 1 , 9 } ) == :none
460
459
461
- for i <- 2 .. 10 do
460
+ for i <- 2 .. 9 do
462
461
assert CF . surround_context ( " hello_wo" , { 1 , i } ) == % {
463
462
context: { :local_or_var , ~c" hello_wo" } ,
464
463
begin: { 1 , 2 } ,
465
464
end: { 1 , 10 }
466
465
}
467
466
end
468
467
469
- assert CF . surround_context ( " hello_wo " , { 1 , 11 } ) == :none
468
+ assert CF . surround_context ( " hello_wo" , { 1 , 10 } ) == :none
470
469
471
- for i <- 1 .. 7 do
470
+ for i <- 1 .. 6 do
472
471
assert CF . surround_context ( "hello!" , { 1 , i } ) == % {
473
472
context: { :local_or_var , ~c" hello!" } ,
474
473
begin: { 1 , 1 } ,
475
474
end: { 1 , 7 }
476
475
}
477
476
end
478
477
479
- assert CF . surround_context ( "hello! " , { 1 , 8 } ) == :none
478
+ assert CF . surround_context ( "hello!" , { 1 , 7 } ) == :none
480
479
481
- for i <- 1 .. 6 do
480
+ for i <- 1 .. 5 do
482
481
assert CF . surround_context ( "안녕_세상" , { 1 , i } ) == % {
483
482
context: { :local_or_var , ~c" 안녕_세상" } ,
484
483
begin: { 1 , 1 } ,
485
484
end: { 1 , 6 }
486
485
}
487
486
end
488
487
489
- assert CF . surround_context ( "안녕_세상 " , { 1 , 6 } ) == :none
488
+ assert CF . surround_context ( "안녕_세상" , { 1 , 6 } ) == :none
490
489
491
490
# Keywords are not local or var
492
491
for keyword <- ~w( do end after catch else rescue fn true false nil) c do
@@ -500,77 +499,46 @@ defmodule CodeFragmentTest do
500
499
end
501
500
end
502
501
503
- test "local + operator" do
504
- for i <- 1 .. 8 do
505
- assert CF . surround_context ( "hello_wo+" , { 1 , i } ) == % {
506
- context: { :local_or_var , ~c" hello_wo" } ,
507
- begin: { 1 , 1 } ,
508
- end: { 1 , 9 }
509
- }
510
- end
511
-
512
- assert CF . surround_context ( "hello_wo+" , { 1 , 9 } ) == % {
513
- begin: { 1 , 9 } ,
514
- context: { :operator , ~c" +" } ,
515
- end: { 1 , 10 }
516
- }
517
-
518
- for i <- 1 .. 9 do
519
- assert CF . surround_context ( "hello_wo +" , { 1 , i } ) == % {
520
- context: { :local_or_var , ~c" hello_wo" } ,
521
- begin: { 1 , 1 } ,
522
- end: { 1 , 9 }
523
- }
524
- end
525
-
526
- assert CF . surround_context ( "hello_wo +" , { 1 , 10 } ) == % {
527
- begin: { 1 , 10 } ,
528
- context: { :operator , ~c" +" } ,
529
- end: { 1 , 11 }
530
- }
531
- end
532
-
533
502
test "local call" do
534
- for i <- 1 .. 9 do
503
+ for i <- 1 .. 8 do
535
504
assert CF . surround_context ( "hello_wo(" , { 1 , i } ) == % {
536
505
context: { :local_call , ~c" hello_wo" } ,
537
506
begin: { 1 , 1 } ,
538
507
end: { 1 , 9 }
539
508
}
540
509
end
541
510
542
- assert CF . surround_context ( "hello_wo(" , { 1 , 10 } ) == :none
511
+ assert CF . surround_context ( "hello_wo(" , { 1 , 9 } ) == :none
543
512
544
- for i <- 1 .. 9 do
513
+ for i <- 1 .. 8 do
545
514
assert CF . surround_context ( "hello_wo (" , { 1 , i } ) == % {
546
515
context: { :local_call , ~c" hello_wo" } ,
547
516
begin: { 1 , 1 } ,
548
517
end: { 1 , 9 }
549
518
}
550
519
end
551
520
552
- assert CF . surround_context ( "hello_wo (" , { 1 , 10 } ) == :none
553
- assert CF . surround_context ( "hello_wo (" , { 1 , 11 } ) == :none
521
+ assert CF . surround_context ( "hello_wo (" , { 1 , 9 } ) == :none
554
522
555
- for i <- 1 .. 7 do
523
+ for i <- 1 .. 6 do
556
524
assert CF . surround_context ( "hello!(" , { 1 , i } ) == % {
557
525
context: { :local_call , ~c" hello!" } ,
558
526
begin: { 1 , 1 } ,
559
527
end: { 1 , 7 }
560
528
}
561
529
end
562
530
563
- assert CF . surround_context ( "hello!(" , { 1 , 8 } ) == :none
531
+ assert CF . surround_context ( "hello!(" , { 1 , 7 } ) == :none
564
532
565
- for i <- 1 .. 6 do
533
+ for i <- 1 .. 5 do
566
534
assert CF . surround_context ( "안녕_세상(" , { 1 , i } ) == % {
567
535
context: { :local_call , ~c" 안녕_세상" } ,
568
536
begin: { 1 , 1 } ,
569
537
end: { 1 , 6 }
570
538
}
571
539
end
572
540
573
- assert CF . surround_context ( "안녕_세상(" , { 1 , 7 } ) == :none
541
+ assert CF . surround_context ( "안녕_세상(" , { 1 , 6 } ) == :none
574
542
end
575
543
576
544
test "local arity" do
@@ -698,47 +666,47 @@ defmodule CodeFragmentTest do
698
666
end
699
667
700
668
test "alias" do
701
- for i <- 1 .. 9 do
669
+ for i <- 1 .. 8 do
702
670
assert CF . surround_context ( "HelloWor" , { 1 , i } ) == % {
703
671
context: { :alias , ~c" HelloWor" } ,
704
672
begin: { 1 , 1 } ,
705
673
end: { 1 , 9 }
706
674
}
707
675
end
708
676
709
- assert CF . surround_context ( "HelloWor " , { 1 , 10 } ) == :none
677
+ assert CF . surround_context ( "HelloWor" , { 1 , 9 } ) == :none
710
678
711
- for i <- 2 .. 10 do
679
+ for i <- 2 .. 9 do
712
680
assert CF . surround_context ( " HelloWor" , { 1 , i } ) == % {
713
681
context: { :alias , ~c" HelloWor" } ,
714
682
begin: { 1 , 2 } ,
715
683
end: { 1 , 10 }
716
684
}
717
685
end
718
686
719
- assert CF . surround_context ( " HelloWor " , { 1 , 11 } ) == :none
687
+ assert CF . surround_context ( " HelloWor" , { 1 , 10 } ) == :none
720
688
721
- for i <- 1 .. 10 do
689
+ for i <- 1 .. 9 do
722
690
assert CF . surround_context ( "Hello.Wor" , { 1 , i } ) == % {
723
691
context: { :alias , ~c" Hello.Wor" } ,
724
692
begin: { 1 , 1 } ,
725
693
end: { 1 , 10 }
726
694
}
727
695
end
728
696
729
- assert CF . surround_context ( "Hello.Wor " , { 1 , 11 } ) == :none
697
+ assert CF . surround_context ( "Hello.Wor" , { 1 , 10 } ) == :none
730
698
731
- for i <- 1 .. 12 do
699
+ for i <- 1 .. 11 do
732
700
assert CF . surround_context ( "Hello . Wor" , { 1 , i } ) == % {
733
701
context: { :alias , ~c" Hello.Wor" } ,
734
702
begin: { 1 , 1 } ,
735
703
end: { 1 , 12 }
736
704
}
737
705
end
738
706
739
- assert CF . surround_context ( "Hello . Wor " , { 1 , 13 } ) == :none
707
+ assert CF . surround_context ( "Hello . Wor" , { 1 , 12 } ) == :none
740
708
741
- for i <- 1 .. 16 do
709
+ for i <- 1 .. 15 do
742
710
assert CF . surround_context ( "Foo . Bar . Baz" , { 1 , i } ) == % {
743
711
context: { :alias , ~c" Foo.Bar.Baz" } ,
744
712
begin: { 1 , 1 } ,
@@ -770,15 +738,15 @@ defmodule CodeFragmentTest do
770
738
end: { 1 , 11 }
771
739
}
772
740
773
- for i <- 1 .. 15 do
741
+ for i <- 1 .. 14 do
774
742
assert CF . surround_context ( "__MODULE__.Foo" , { 1 , i } ) == % {
775
743
context: { :alias , { :local_or_var , ~c" __MODULE__" } , ~c" Foo" } ,
776
744
begin: { 1 , 1 } ,
777
745
end: { 1 , 15 }
778
746
}
779
747
end
780
748
781
- for i <- 1 .. 19 do
749
+ for i <- 1 .. 18 do
782
750
assert CF . surround_context ( "__MODULE__.Foo.Sub" , { 1 , i } ) == % {
783
751
context: { :alias , { :local_or_var , ~c" __MODULE__" } , ~c" Foo.Sub" } ,
784
752
begin: { 1 , 1 } ,
@@ -830,15 +798,15 @@ defmodule CodeFragmentTest do
830
798
end
831
799
832
800
test "attribute submodules" do
833
- for i <- 1 .. 10 do
801
+ for i <- 1 .. 9 do
834
802
assert CF . surround_context ( "@some.Foo" , { 1 , i } ) == % {
835
803
context: { :alias , { :module_attribute , ~c" some" } , ~c" Foo" } ,
836
804
begin: { 1 , 1 } ,
837
805
end: { 1 , 10 }
838
806
}
839
807
end
840
808
841
- for i <- 1 .. 14 do
809
+ for i <- 1 .. 13 do
842
810
assert CF . surround_context ( "@some.Foo.Sub" , { 1 , i } ) == % {
843
811
context: { :alias , { :module_attribute , ~c" some" } , ~c" Foo.Sub" } ,
844
812
begin: { 1 , 1 } ,
@@ -921,15 +889,15 @@ defmodule CodeFragmentTest do
921
889
end: { 1 , 15 }
922
890
}
923
891
924
- for i <- 2 .. 10 do
892
+ for i <- 2 .. 9 do
925
893
assert CF . surround_context ( "%HelloWor" , { 1 , i } ) == % {
926
894
context: { :struct , ~c" HelloWor" } ,
927
895
begin: { 1 , 1 } ,
928
896
end: { 1 , 10 }
929
897
}
930
898
end
931
899
932
- assert CF . surround_context ( "%HelloWor " , { 1 , 11 } ) == :none
900
+ assert CF . surround_context ( "%HelloWor" , { 1 , 10 } ) == :none
933
901
934
902
# With dot
935
903
assert CF . surround_context ( "%Hello.Wor" , { 1 , 1 } ) == % {
@@ -938,15 +906,15 @@ defmodule CodeFragmentTest do
938
906
end: { 1 , 11 }
939
907
}
940
908
941
- for i <- 2 .. 11 do
909
+ for i <- 2 .. 10 do
942
910
assert CF . surround_context ( "%Hello.Wor" , { 1 , i } ) == % {
943
911
context: { :struct , ~c" Hello.Wor" } ,
944
912
begin: { 1 , 1 } ,
945
913
end: { 1 , 11 }
946
914
}
947
915
end
948
916
949
- assert CF . surround_context ( "%Hello.Wor " , { 1 , 12 } ) == :none
917
+ assert CF . surround_context ( "%Hello.Wor" , { 1 , 11 } ) == :none
950
918
951
919
# With spaces
952
920
assert CF . surround_context ( "% Hello . Wor" , { 1 , 1 } ) == % {
@@ -955,15 +923,15 @@ defmodule CodeFragmentTest do
955
923
end: { 1 , 14 }
956
924
}
957
925
958
- for i <- 2 .. 14 do
926
+ for i <- 2 .. 13 do
959
927
assert CF . surround_context ( "% Hello . Wor" , { 1 , i } ) == % {
960
928
context: { :struct , ~c" Hello.Wor" } ,
961
929
begin: { 1 , 1 } ,
962
930
end: { 1 , 14 }
963
931
}
964
932
end
965
933
966
- assert CF . surround_context ( "% Hello . Wor " , { 1 , 15 } ) == :none
934
+ assert CF . surround_context ( "% Hello . Wor" , { 1 , 14 } ) == :none
967
935
end
968
936
969
937
test "module attributes" do
0 commit comments