Skip to content

Commit 4f59208

Browse files
authored
Fix tests (#170)
For some reason, locally, bs-platform is resolved before rescript, and on CI there's no bs-platform. So on CI we have the newest doc blocks from rescript, while locally we have the old ones. This makes the analysis get rescript first. As for why ci doesn't install bs-platform: maybe node/npm version difference.
1 parent 313816c commit 4f59208

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

analysis/src/BuildSystem.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ open Infix
77

88
let getBsPlatformDir rootPath =
99
let result =
10-
ModuleResolution.resolveNodeModulePath ~startPath:rootPath "bs-platform"
10+
ModuleResolution.resolveNodeModulePath ~startPath:rootPath "rescript"
1111
in
1212
let result =
1313
if result = None then
14-
ModuleResolution.resolveNodeModulePath ~startPath:rootPath "rescript"
14+
ModuleResolution.resolveNodeModulePath ~startPath:rootPath "bs-platform"
1515
else result
1616
in
1717
match result with

analysis/src/Commands.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ let documentSymbol ~path =
172172
| Module (Structure contents) -> (Module, getItems contents)
173173
| Module (Ident _) -> (Module, [])
174174
in
175-
(txt, extentLoc, item) :: siblings
175+
if extentLoc.loc_ghost then siblings
176+
else (txt, extentLoc, item) :: siblings
176177
in
177178
let x = topLevel |> List.map fn |> List.concat in
178179
x

analysis/test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function exp {
22
echo "$(dirname $1)/expected/$(basename $1).txt"
33
}
44

5-
for file in tests/src/*.res[i]; do
5+
for file in tests/src/*.{res,resi}; do
66
./rescript-editor-analysis.exe test $file &> $(exp $file)
77
done
88

@@ -15,5 +15,6 @@ if [[ $diff = "" ]]; then
1515
printf "${successGreen}✅ No unstaged tests difference.${reset}\n"
1616
else
1717
printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}"
18+
git --no-pager diff tests/src/expected
1819
exit 1
1920
fi
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Hover tests/src/Auto.res 2:13
2-
{"contents": "```rescript\n(Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b>\n```\n\n\n [map xs f]\n\n return the list obtained by applying [f] to each element of [xs]\n\n @example {[\n map [1;2] (fun x-> x + 1) = [3;4]\n ]}\n"}
2+
{"contents": "```rescript\n(Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b>\n```\n\n\n `map xs f`\n\n **return** the list obtained by applying `f` to each element of `xs`\n\n ```\n map [1;2] (fun x-> x + 1) = [3;4]\n ```\n"}
33

analysis/tests/src/expected/Complete.res.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Complete tests/src/Complete.res 0:2
44
"kind": 12,
55
"tags": [],
66
"detail": "(t<'a>, 'a => 'b) => t<'b>",
7-
"documentation": {"kind": "markdown", "value": " [mapReverse xs f]\n\n Equivalent to [reverse (map xs f)]\n\n @example {[\n mapReverse [3;4;5] (fun x -> x * x) = [25;16;9];;\n ]}\n"}
7+
"documentation": {"kind": "markdown", "value": "\n `mapReverse xs f`\n\n Equivalent to `reverse (map xs f)`\n\n ```\n mapReverse [3;4;5] (fun x -> x * x) = [25;16;9];;\n ```\n"}
88
}, {
99
"label": "makeBy",
1010
"kind": 12,
1111
"tags": [],
1212
"detail": "(int, int => 'a) => t<'a>",
13-
"documentation": {"kind": "markdown", "value": " [makeBy n f] \n\n - return a list of length [n] with element [i] initialized with [f i]\n - return the empty list if [n] is negative\n\n @example {[\n makeBy 5 (fun i -> i) = [0;1;2;3;4];;\n makeBy 5 (fun i -> i * i) = [0;1;4;9;16];;\n ]}\n"}
13+
"documentation": {"kind": "markdown", "value": "\n `makeBy n f`\n\n **return** a list of length `n` with element `i` initialized with `f i`\n\n **return** the empty list if `n` is negative\n\n ```\n makeBy 5 (fun i -> i) = [0;1;2;3;4];;\n makeBy 5 (fun i -> i * i) = [0;1;4;9;16];;\n ```\n"}
1414
}, {
1515
"label": "make",
1616
"kind": 12,
1717
"tags": [],
1818
"detail": "(int, 'a) => t<'a>",
19-
"documentation": {"kind": "markdown", "value": " [make n v] \n\n - return a list of length [n] with each element filled with value [v] \n - return the empty list if [n] is negative\n\n @example {[\n make 3 1 = [1;1;1]\n ]}\n"}
19+
"documentation": {"kind": "markdown", "value": "\n `make n v`\n\n **return** a list of length `n` with each element filled with value `v`\n\n **return** the empty list if `n` is negative\n\n ```\n make 3 1 = [1;1;1]\n ```\n"}
2020
}, {
2121
"label": "mapReverse2U",
2222
"kind": 12,
@@ -28,7 +28,7 @@ Complete tests/src/Complete.res 0:2
2828
"kind": 12,
2929
"tags": [],
3030
"detail": "(t<'a>, 'a => 'b) => t<'b>",
31-
"documentation": {"kind": "markdown", "value": "\n [map xs f]\n\n return the list obtained by applying [f] to each element of [xs]\n\n @example {[\n map [1;2] (fun x-> x + 1) = [3;4]\n ]}\n"}
31+
"documentation": {"kind": "markdown", "value": "\n `map xs f`\n\n **return** the list obtained by applying `f` to each element of `xs`\n\n ```\n map [1;2] (fun x-> x + 1) = [3;4]\n ```\n"}
3232
}, {
3333
"label": "mapWithIndexU",
3434
"kind": 12,
@@ -52,13 +52,13 @@ Complete tests/src/Complete.res 0:2
5252
"kind": 12,
5353
"tags": [],
5454
"detail": "(t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c>",
55-
"documentation": {"kind": "markdown", "value": " [mapReverse2 xs ys f]\n\n equivalent to [reverse (zipBy xs ys f)] \n\n @example {[\n mapReverse2 [1;2;3] [1;2] (+) = [4;2]\n ]}\n"}
55+
"documentation": {"kind": "markdown", "value": "\n `mapReverse2 xs ys f`\n\n equivalent to `reverse (zipBy xs ys f)`\n\n ```\n mapReverse2 [1;2;3] [1;2] (+) = [4;2]\n ```\n"}
5656
}, {
5757
"label": "mapWithIndex",
5858
"kind": 12,
5959
"tags": [],
6060
"detail": "(t<'a>, (int, 'a) => 'b) => t<'b>",
61-
"documentation": {"kind": "markdown", "value": " [mapWithIndex xs f] applies [f] to each element of [xs]. Function [f] takes two arguments:\n the index starting from 0 and the element from [xs].\n\n @example {[\n mapWithIndex [1;2;3] (fun i x -> i + x) =\n [0 + 1; 1 + 2; 2 + 3 ]\n ]}\n"}
61+
"documentation": {"kind": "markdown", "value": "\n `mapWithIndex xs f` applies `f` to each element of `xs`. Function `f` takes two arguments:\n the index starting from 0 and the element from `xs`.\n\n ```\n mapWithIndex [1;2;3] (fun i x -> i + x) =\n [0 + 1; 1 + 2; 2 + 3 ]\n ```\n"}
6262
}, {
6363
"label": "mapReverseU",
6464
"kind": 12,
@@ -382,7 +382,7 @@ Complete tests/src/Complete.res 23:2
382382
"kind": 12,
383383
"tags": [],
384384
"detail": "t => t",
385-
"documentation": {"kind": "markdown", "value": "\n [toUpperCase str] converts [str] to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German [ß] capitalizes to two [S]es in a row.\n\n@example {[\n toUpperCase \"abc\" = \"ABC\";;\n toUpperCase {js|Straße|js} = {js|STRASSE|js};;\n toLowerCase {js|πς|js} = {js|ΠΣ|js};;\n]}\n"}
385+
"documentation": {"kind": "markdown", "value": "\n `toUpperCase str` converts `str` to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German `ß` capitalizes to two `S`es in a row.\n\n ```\n toUpperCase \"abc\" = \"ABC\";;\n toUpperCase {js|Straße|js} = {js|STRASSE|js};;\n toLowerCase {js|πς|js} = {js|ΠΣ|js};;\n ```\n"}
386386
}]
387387

388388
Complete tests/src/Complete.res 27:2
@@ -391,13 +391,13 @@ Complete tests/src/Complete.res 27:2
391391
"kind": 12,
392392
"tags": [],
393393
"detail": "(option<'a>, option<'b>, (. 'a, 'b) => bool) => bool",
394-
"documentation": {"kind": "markdown", "value": "\n Uncurried version of [eq]\n"}
394+
"documentation": {"kind": "markdown", "value": "\n Uncurried version of `eq`\n"}
395395
}, {
396396
"label": "Belt.Option.eq",
397397
"kind": 12,
398398
"tags": [],
399399
"detail": "(option<'a>, option<'b>, ('a, 'b) => bool) => bool",
400-
"documentation": {"kind": "markdown", "value": "\n [eq optValue1 optvalue2 predicate]\n\n Evaluates two optional values for equality with respect to a predicate function.\n\n If both [optValue1] and [optValue2] are [None], returns [true].\n\n If one of the arguments is [Some value] and the other is [None], returns [false]\n\n If arguments are [Some value1] and [Some value2], returns the result of [predicate value1 value2];\n the [predicate] function must return a [bool]\n\n @example {[\n let clockEqual = (fun a b -> a mod 12 = b mod 12);;\n eq (Some 3) (Some 15) clockEqual = true;;\n eq (Some 3) None clockEqual = false;;\n eq None (Some 3) clockEqual = false;;\n eq None None clockEqual = true;;\n ]}\n"}
400+
"documentation": {"kind": "markdown", "value": "\n `eq optValue1 optvalue2 predicate`\n\n Evaluates two optional values for equality with respect to a predicate function.\n\n If both `optValue1` and `optValue2` are `None`, returns `true`.\n\n If one of the arguments is `Some value` and the other is `None`, returns `false`\n\n If arguments are `Some value1` and `Some value2`, returns the result of `predicate value1 value2`;\n the `predicate` function must return a `bool`\n\n ```\n let clockEqual = (fun a b -> a mod 12 = b mod 12);;\n eq (Some 3) (Some 15) clockEqual = true;;\n eq (Some 3) None clockEqual = false;;\n eq None (Some 3) clockEqual = false;;\n eq None None clockEqual = true;;\n ```\n"}
401401
}]
402402

403403
Complete tests/src/Complete.res 36:2
@@ -421,7 +421,7 @@ Complete tests/src/Complete.res 38:2
421421
"kind": 12,
422422
"tags": [],
423423
"detail": "(t<'a>, key) => 'a",
424-
"documentation": {"kind": "markdown", "value": " [unsafeGet dict key] return the value if the [key] exists, \n otherwise an {b undefined} value is returned. Must be used only \n when the existence of a key is certain. (i.e. when having called [keys]\n function previously. \n\n @example {[\n Array.iter (fun key -> Js.log (Js_dict.unsafeGet dic key)) (Js_dict.keys dict) \n ]} \n"}
424+
"documentation": {"kind": "markdown", "value": "\n `unsafeGet dict key` return the value if the `key` exists,\n otherwise an **undefined** value is returned. Must be used only\n when the existence of a key is certain. (i.e. when having called `keys`\n function previously.\n\n ```\n Array.iter (fun key -> Js.log (Js_dict.unsafeGet dic key)) (Js_dict.keys dict)\n ```\n"}
425425
}, {
426426
"label": "unsafeDeleteKey",
427427
"kind": 12,

analysis/tests/src/expected/Definition.res.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Hover tests/src/Definition.res 14:14
88
{"contents": "```rescript\n('a => 'b, list<'a>) => list<'b>\n```\n\n [List.map f [a1; ...; an]] applies function [f] to [a1, ..., an],\n and builds the list [[f a1; ...; f an]]\n with the results returned by [f]. Not tail-recursive. "}
99

1010
Hover tests/src/Definition.res 18:14
11-
{"contents": "```rescript\n(Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b>\n```\n\n\n [map xs f]\n\n return the list obtained by applying [f] to each element of [xs]\n\n @example {[\n map [1;2] (fun x-> x + 1) = [3;4]\n ]}\n"}
11+
{"contents": "```rescript\n(Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b>\n```\n\n\n `map xs f`\n\n **return** the list obtained by applying `f` to each element of `xs`\n\n ```\n map [1;2] (fun x-> x + 1) = [3;4]\n ```\n"}
1212

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)