Skip to content

Commit 6b4acd0

Browse files
committed
add tests
1 parent c74af0a commit 6b4acd0

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

analysis/src/Commands.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ let diagnosticSyntax ~path =
261261
print_endline
262262
(match Diagnostics.document_syntax ~path with
263263
| [] -> Protocol.null
264-
| d -> "[\n" ^ String.concat ",\n" d ^ "\n]")
264+
| d -> Protocol.array d)
265265

266266
let test ~path =
267267
Uri.stripPath := true;
@@ -384,6 +384,7 @@ let test ~path =
384384
Printf.printf "%s\nnewText:\n%s<--here\n%s%s\n"
385385
(Protocol.stringifyRange range)
386386
indent indent newText)))
387+
| "dia" -> diagnosticSyntax ~path
387388
| _ -> ());
388389
print_newline ())
389390
in

analysis/src/Diagnostics.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let document_syntax ~path =
77
| [] -> []
88
| diagnostics ->
99
diagnostics
10-
|> List.map (fun diagnostic ->
10+
|> List.rev_map (fun diagnostic ->
1111
let _, startline, startcol =
1212
Location.get_pos_info (Res_diagnostics.getStartPos diagnostic)
1313
in
@@ -23,5 +23,4 @@ let document_syntax ~path =
2323
};
2424
message = Res_diagnostics.explain diagnostic;
2525
severity = Error;
26-
})
27-
|> List.rev
26+
})

analysis/tests/bsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"subdirs": true
1010
}
1111
],
12+
"ignored-dirs": ["src/not_compiled"],
1213
"bsc-flags": ["-w -33-44"],
1314
"bs-dependencies": ["@rescript/react"],
1415
"reason": { "react-jsx": 3 }
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
let = 1 + 1.0
22
let add = =2
3-
lett a = 2
3+
lett a = 2
4+
5+
//^dia
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[{
2+
"range: {"start": {"line": 1, "character": 4}, "end": {"line": 1, "character": 5}},
3+
"message": "I was expecting a name for this let-binding. Example: `let message = \"hello\"`",
4+
"severity": 1,
5+
}, {
6+
"range: {"start": {"line": 2, "character": 9}, "end": {"line": 2, "character": 11}},
7+
"message": "This let-binding misses an expression",
8+
"severity": 1,
9+
}, {
10+
"range: {"start": {"line": 3, "character": 4}, "end": {"line": 3, "character": 6}},
11+
"message": "consecutive statements on a line must be separated by ';' or a newline",
12+
"severity": 1,
13+
}]

analysis/tests/test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ for file in src/*.{res,resi}; do
77
fi
88
done
99

10+
for file in src/not_compiled/*.res; do
11+
output="$(dirname $file)/expected/$(basename $file).txt"
12+
../rescript-editor-analysis.exe test $file &> $output
13+
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
14+
if [ "$RUNNER_OS" == "Windows" ]; then
15+
perl -pi -e 's/\r\n/\n/g' -- $output
16+
fi
17+
done
18+
1019
warningYellow='\033[0;33m'
1120
successGreen='\033[0;32m'
1221
reset='\033[0m'

0 commit comments

Comments
 (0)