Play

Check-in [a897d19fce]
Login
Overview
Comment:Re-enable and correct source location test.
Timelines: family | ancestors | descendants | both | alpha2-syntax-changes
Files: files | file ages | folders
SHA3-256: a897d19fcebd8d76d90978aecf22ed9f2c6824044058f4f7de71ee47106b6551
User & Date: robin.hansen on 2021-01-23 17:41:36
Other Links: branch diff | manifest | tags
Context
2021-01-24
07:12
When defining multiwords, : now replaces when:, else: replaces :. check-in: 1b2a7e4296 user: robin.hansen tags: alpha2-syntax-changes
2021-01-23
17:41
Re-enable and correct source location test. check-in: a897d19fce user: robin.hansen tags: alpha2-syntax-changes
15:11
Structs with no members now doesn't have a leading > in their constructor name. Only the compiler ca... check-in: 25fd54d4db user: robin.hansen tags: alpha2-syntax-changes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified tests/Test/Parser.elm from [8e99ba724c] to [afb57faec7].

746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
                    : 1
                      # + wouldnt work here
                      -

                    # And thats it!
                     # wonder what else we should do...
                    """

        {- , test "Correct line information" <|
           \_ ->
               let
                   source =
                       """
                       defunion: Bool
                       : True
                       : False

                       defstruct: True
                       defstruct: False

                       defmulti: from-int
                       type: Int -- Int
                       when: Int( value 0 )
                         >False
                       when: Int
                         >True

                       def: equal
                       : - from-int not

                       defmulti: not
                       when: True
                         >False
                       : >True
                       """

                   -- The ending source location for most definitions now ends where the next definition beings
                   -- This is not what we want (it includes too much white space), but it'll do for now.
                   expectedAst =
                       { types =
                           Dict.fromListBy AST.typeDefinitionName
                               [ UnionTypeDef
                                   (SourceLocationRange
                                       (SourceLocation 2 1 1)
                                       (SourceLocation 6 1 32)
                                   )
                                   "Bool"
                                   []
                                   [ Type.Custom "True"
                                   , Type.Custom "False"
                                   ]
                               , CustomTypeDef
                                   (SourceLocationRange
                                       (SourceLocation 6 1 32)
                                       (SourceLocation 7 1 46)
                                   )
                                   "True"
                                   []
                                   []
                               , CustomTypeDef
                                   (SourceLocationRange
                                       (SourceLocation 7 1 46)
                                       (SourceLocation 9 1 62)
                                   )
                                   "False"
                                   []
                                   []
                               ]
                       , words =
                           Dict.fromListBy .name
                               [ { name = ">True"
                                 , metadata =
                                       Metadata.default
                                           |> Metadata.withVerifiedType [] [ Type.Custom "True" ]
                                 , implementation = SoloImpl [ ConstructType "True" ]
                                 }
                               , { name = ">False"
                                 , metadata =
                                       Metadata.default
                                           |> Metadata.withVerifiedType [] [ Type.Custom "False" ]
                                 , implementation = SoloImpl [ ConstructType "False" ]
                                 }
                               , { name = "from-int"
                                 , metadata =
                                       Metadata.default
                                           |> Metadata.withType [ Type.Int ] [ Type.Int ]
                                           |> Metadata.withSourceLocationRange
                                               (SourceLocationRange
                                                   (SourceLocation 9 1 62)
                                                   (SourceLocation 16 1 147)
                                               )
                                 , implementation =
                                       MultiImpl
                                           [ ( TypeMatch
                                                   (SourceLocationRange
                                                       (SourceLocation 11 7 104)
                                                       (SourceLocation 11 21 118)
                                                   )
                                                   Type.Int
                                                   [ ( "value", LiteralInt 0 ) ]
                                             , [ Word
                                                   (SourceLocationRange
                                                       (SourceLocation 12 3 121)
                                                       (SourceLocation 13 1 128)
                                                   )
                                                   ">False"
                                               ]
                                             )
                                           , ( TypeMatch
                                                   (SourceLocationRange
                                                       (SourceLocation 13 7 134)
                                                       (SourceLocation 14 3 140)
                                                   )
                                                   Type.Int
                                                   []
                                             , [ Word
                                                   (SourceLocationRange
                                                       (SourceLocation 14 3 140)
                                                       (SourceLocation 16 1 147)
                                                   )
                                                   ">True"
                                               ]
                                             )
                                           ]
                                           []
                                 }
                               , { name = "equal"
                                 , metadata =
                                       Metadata.default
                                           |> Metadata.withSourceLocationRange
                                               (SourceLocationRange
                                                   (SourceLocation 16 1 147)
                                                   (SourceLocation 19 1 176)
                                               )
                                 , implementation =
                                       SoloImpl
                                           [ Word
                                               (SourceLocationRange
                                                   (SourceLocation 17 3 160)
                                                   (SourceLocation 17 5 162)
                                               )
                                               "-"
                                           , Word
                                               (SourceLocationRange
                                                   (SourceLocation 17 5 162)
                                                   (SourceLocation 17 14 171)
                                               )
                                               "from-int"
                                           , Word
                                               (SourceLocationRange
                                                   (SourceLocation 17 14 171)
                                                   (SourceLocation 19 1 176)
                                               )
                                               "not"
                                           ]
                                 }
                               , { name = "not"
                                 , metadata =
                                       Metadata.default
                                           |> Metadata.withSourceLocationRange
                                               (SourceLocationRange
                                                   (SourceLocation 19 1 176)
                                                   (SourceLocation 23 1 218)
                                               )
                                 , implementation =
                                       MultiImpl
                                           [ ( TypeMatch
                                                   (SourceLocationRange
                                                       (SourceLocation 20 7 196)
                                                       (SourceLocation 21 3 203)
                                                   )
                                                   (Type.Custom "True")
                                                   []
                                             , [ Word
                                                   (SourceLocationRange
                                                       (SourceLocation 21 3 203)
                                                       (SourceLocation 22 1 210)
                                                   )
                                                   ">False"
                                               ]
                                             )
                                           ]
                                           [ Word
                                               (SourceLocationRange
                                                   (SourceLocation 22 3 212)
                                                   (SourceLocation 23 1 218)
                                               )
                                               ">True"
                                           ]
                                 }
                               ]
                       }
               in
               case compileRetainLocations source of
                   Err _ ->
                       Expect.fail "Did not expect compilation to fail."

                   Ok ast ->
                       Expect.equal expectedAst ast
        -}
        ]







<
|
|
|
|
|










|

|






|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
<

746
747
748
749
750
751
752

753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943

944
                    : 1
                      # + wouldnt work here
                      -

                    # And thats it!
                     # wonder what else we should do...
                    """

        , test "Correct line information" <|
            \_ ->
                let
                    source =
                        """
                       defunion: Bool
                       : True
                       : False

                       defstruct: True
                       defstruct: False

                       defmulti: from-int
                       type: Int -- Int
                       when: Int( value 0 )
                         False
                       when: Int
                         True

                       def: equal
                       : - from-int not

                       defmulti: not
                       when: True
                         False
                       : True
                       """

                    -- The ending source location for most definitions now ends where the next definition beings
                    -- This is not what we want (it includes too much white space), but it'll do for now.
                    expectedAst =
                        { types =
                            Dict.fromListBy AST.typeDefinitionName
                                [ UnionTypeDef
                                    (SourceLocationRange
                                        (SourceLocation 2 1 1)
                                        (SourceLocation 6 1 32)
                                    )
                                    "Bool"
                                    []
                                    [ Type.Custom "True"
                                    , Type.Custom "False"
                                    ]
                                , CustomTypeDef
                                    (SourceLocationRange
                                        (SourceLocation 6 1 32)
                                        (SourceLocation 7 1 48)
                                    )
                                    "True"
                                    []
                                    []
                                , CustomTypeDef
                                    (SourceLocationRange
                                        (SourceLocation 7 1 48)
                                        (SourceLocation 9 1 66)
                                    )
                                    "False"
                                    []
                                    []
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "True"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [] [ Type.Custom "True" ]
                                  , implementation = SoloImpl [ ConstructType "True" ]
                                  }
                                , { name = "False"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [] [ Type.Custom "False" ]
                                  , implementation = SoloImpl [ ConstructType "False" ]
                                  }
                                , { name = "from-int"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType [ Type.Int ] [ Type.Int ]
                                            |> Metadata.withSourceLocationRange
                                                (SourceLocationRange
                                                    (SourceLocation 9 1 66)
                                                    (SourceLocation 16 1 149)
                                                )
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatch
                                                    (SourceLocationRange
                                                        (SourceLocation 11 7 108)
                                                        (SourceLocation 11 21 122)
                                                    )
                                                    Type.Int
                                                    [ ( "value", LiteralInt 0 ) ]
                                              , [ Word
                                                    (SourceLocationRange
                                                        (SourceLocation 12 3 125)
                                                        (SourceLocation 13 1 131)
                                                    )
                                                    "False"
                                                ]
                                              )
                                            , ( TypeMatch
                                                    (SourceLocationRange
                                                        (SourceLocation 13 7 137)
                                                        (SourceLocation 14 3 143)
                                                    )
                                                    Type.Int
                                                    []
                                              , [ Word
                                                    (SourceLocationRange
                                                        (SourceLocation 14 3 143)
                                                        (SourceLocation 16 1 149)
                                                    )
                                                    "True"
                                                ]
                                              )
                                            ]
                                            []
                                  }
                                , { name = "equal"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withSourceLocationRange
                                                (SourceLocationRange
                                                    (SourceLocation 16 1 149)
                                                    (SourceLocation 19 1 178)
                                                )
                                  , implementation =
                                        SoloImpl
                                            [ Word
                                                (SourceLocationRange
                                                    (SourceLocation 17 3 162)
                                                    (SourceLocation 17 5 164)
                                                )
                                                "-"
                                            , Word
                                                (SourceLocationRange
                                                    (SourceLocation 17 5 164)
                                                    (SourceLocation 17 14 173)
                                                )
                                                "from-int"
                                            , Word
                                                (SourceLocationRange
                                                    (SourceLocation 17 14 173)
                                                    (SourceLocation 19 1 178)
                                                )
                                                "not"
                                            ]
                                  }
                                , { name = "not"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withSourceLocationRange
                                                (SourceLocationRange
                                                    (SourceLocation 19 1 178)
                                                    (SourceLocation 23 1 218)
                                                )
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatch
                                                    (SourceLocationRange
                                                        (SourceLocation 20 7 198)
                                                        (SourceLocation 21 3 205)
                                                    )
                                                    (Type.Custom "True")
                                                    []
                                              , [ Word
                                                    (SourceLocationRange
                                                        (SourceLocation 21 3 205)
                                                        (SourceLocation 22 1 211)
                                                    )
                                                    "False"
                                                ]
                                              )
                                            ]
                                            [ Word
                                                (SourceLocationRange
                                                    (SourceLocation 22 3 213)
                                                    (SourceLocation 23 1 218)
                                                )
                                                "True"
                                            ]
                                  }
                                ]
                        }
                in
                case compileRetainLocations source of
                    Err _ ->
                        Expect.fail "Did not expect compilation to fail."

                    Ok ast ->
                        Expect.equal expectedAst ast

        ]