Overview
Comment: | On second thought, externalModules should be a module => package dict. |
---|---|
Timelines: | family | ancestors | descendants | both | modules |
Files: | files | file ages | folders |
SHA3-256: |
9a52bbbd5e1042c38fbf5c94512ebd87 |
User & Date: | robin.hansen on 2021-02-11 11:50:12 |
Other Links: | branch diff | manifest | tags |
Context
2021-02-11
| ||
12:56 | Can now resolve external word references. check-in: 4ed17683cd user: robin.hansen tags: modules | |
11:50 | On second thought, externalModules should be a module => package dict. check-in: 9a52bbbd5e user: robin.hansen tags: modules | |
09:27 | Require a list of external modules, so qualifier can validate external module references. check-in: 18c7d0bfa4 user: robin.hansen tags: modules | |
Changes
Modified src/Play/Qualifier.elm from [ab2dcebd3f] to [6228d648c3].
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
]
type alias RunConfig =
{ packageName : String
, modulePath : String
, ast : Parser.AST
, externalModules : List String
}
run : RunConfig -> Result (List Problem) AST
run config =
let
( typeErrors, qualifiedTypes ) =
|
| |
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
]
type alias RunConfig =
{ packageName : String
, modulePath : String
, ast : Parser.AST
, externalModules : Dict String String
}
run : RunConfig -> Result (List Problem) AST
run config =
let
( typeErrors, qualifiedTypes ) =
|
Modified tests/Test/Qualifier.elm from [abab48f2d8] to [34e6530c10].
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
...
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
|
} result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = [] } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> ................................................................................ } result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = [] } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> Expect.equal expectedAst actualAst ] ] |
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
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
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
....
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
} result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = Dict.empty } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> Expect.equal expectedAst actualAst , test "Detects external reference in simple word" <| \_ -> let unqualifiedAst = { types = Dict.empty , words = Dict.fromListBy .name [ { name = "call-external" , metadata = Metadata.default , implementation = AST.SoloImpl [ AST.ExternalWord emptyRange [ "package", "module" ] "sample" ] } ] } expectedAst = { additionalModulesRequired = Set.fromList [ "/external/test/package/module" ] , checkForExistingTypes = Set.empty , checkForExistingWords = Set.fromList [ "/external/test/package/module/sample" ] , types = Dict.empty , words = Dict.fromListBy .name [ { name = "/play/test/package/tests/call-external" , metadata = Metadata.default , implementation = SoloImpl [ Word emptyRange "/external/test/package/module/sample" ] } ] } result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = Dict.fromList [ ( "/package/module", "external/test" ) ] } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> ................................................................................ } result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = Dict.empty } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> Expect.equal expectedAst actualAst , test "Detects external reference in multiword" <| \_ -> let unqualifiedAst = { types = Dict.empty , words = Dict.fromListBy .name [ { name = "call-external" , metadata = Metadata.default , implementation = AST.MultiImpl [ ( AST.TypeMatch emptyRange Type.Int [ ( "value", AST.LiteralInt 1 ) ] , [ AST.ExternalWord emptyRange [ "package", "module" ] "when-one" ] ) ] [ AST.ExternalWord emptyRange [ "package", "module" ] "when-other-one" ] } ] } expectedAst = { additionalModulesRequired = Set.fromList [ "/external/test/package/module" ] , checkForExistingTypes = Set.empty , checkForExistingWords = Set.fromList [ "/external/test/package/module/when-one" , "/external/test/package/module/when-other-one" ] , types = Dict.empty , words = Dict.fromListBy .name [ { name = "/play/test/package/tests/call-external" , metadata = Metadata.default , implementation = MultiImpl [ ( TypeMatch emptyRange Type.Int [ ( "value", LiteralInt 1 ) ] , [ Word emptyRange "/external/test/package/module/when-one" ] ) ] [ Word emptyRange "/external/test/package/module/when-other-one" ] } ] } result = run { packageName = "play/test" , modulePath = "package/tests" , ast = unqualifiedAst , externalModules = Dict.fromList [ ( "/package/module", "external/test" ) ] } in case result of Err err -> Expect.fail <| "Did not expect qualification to fail with error: " ++ Debug.toString err Ok actualAst -> Expect.equal expectedAst actualAst ] ] |
Modified tests/Test/Qualifier/Error.elm from [b8782311a5] to [83e86d1bc6].
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
checkForError fn source =
let
result =
run
{ packageName = ""
, modulePath = ""
, ast = source
, externalModules = []
}
in
case result of
Err errors ->
if List.any fn errors then
Expect.pass
else
Expect.fail <| "Failed for unexpected reason: " ++ Debug.toString errors
Ok _ ->
Expect.fail "Did not expect parsing to succeed"
|
| |
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
checkForError fn source =
let
result =
run
{ packageName = ""
, modulePath = ""
, ast = source
, externalModules = Dict.empty
}
in
case result of
Err errors ->
if List.any fn errors then
Expect.pass
else
Expect.fail <| "Failed for unexpected reason: " ++ Debug.toString errors
Ok _ ->
Expect.fail "Did not expect parsing to succeed"
|
Modified tests/Test/Qualifier/Util.elm from [40a2baa166] to [347c700b83].
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
expectOutput parserAst expectedAst = let result = AST.run { packageName = "" , modulePath = "" , ast = parserAst , externalModules = [] } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> ................................................................................ expectModuleOutput parserAst expectedAst = let result = AST.run { packageName = "play/test" , modulePath = "some/module" , ast = parserAst , externalModules = [] } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> |
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
expectOutput parserAst expectedAst = let result = AST.run { packageName = "" , modulePath = "" , ast = parserAst , externalModules = Dict.empty } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> ................................................................................ expectModuleOutput parserAst expectedAst = let result = AST.run { packageName = "play/test" , modulePath = "some/module" , ast = parserAst , externalModules = Dict.empty } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> |