Skip to content

Commit 090f852

Browse files
committed
Test: 5.3 compatibility
1 parent f119e81 commit 090f852

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

test/extract_code/mld_extraction.t/main.mld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ printf(a,10,34,a,34);
1515
}
1616
]}
1717

18-
{@ocaml name=error.ml name=printing[let x = 5]}
18+
{@ocaml name=error.ml name=printing[let five = 5]}
1919

2020
{@ocaml name=printing[
21-
let () = print_int x
21+
let () = print_int five
2222
]}
2323

2424

2525
{@ocaml name=error.ml[
26-
let y = x + 6. (* This is a typing error *)
26+
let y = five +. five (* This is a typing error *)
2727
]}

test/extract_code/mld_extraction.t/run.t

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Without --name argument, all **OCaml** code blocks are extracted
66

77
(** By default, an odoc code block is assumed to contain OCaml code *)
88
let () = ()
9-
let x = 5
10-
let () = print_int x
9+
let five = 5
10+
let () = print_int five
1111

12-
let y = x + 6. (* This is a typing error *)
12+
let y = five +. five (* This is a typing error *)
1313

1414

1515
With --name argument, language does not matter
@@ -26,14 +26,14 @@ Multiple name can be given
2626

2727
$ odoc extract-code --line-directives --name error.ml --name printing main.mld
2828
#18 "main.mld"
29-
let x = 5
29+
let five = 5
3030
#20 "main.mld"
3131

32-
let () = print_int x
32+
let () = print_int five
3333

3434
#25 "main.mld"
3535

36-
let y = x + 6. (* This is a typing error *)
36+
let y = five +. five (* This is a typing error *)
3737

3838

3939
------- Line directives ---------------------------------------
@@ -47,49 +47,50 @@ We can add (OCaml) line directives
4747
let () = ()
4848

4949
#18 "main.mld"
50-
let x = 5
50+
let five = 5
5151
#20 "main.mld"
5252

53-
let () = print_int x
53+
let () = print_int five
5454

5555
#25 "main.mld"
5656

57-
let y = x + 6. (* This is a typing error *)
57+
let y = five +. five (* This is a typing error *)
5858

5959

6060
Let's restrict to a named code blocks
6161

6262
$ odoc extract-code --line-directives --name error.ml main.mld
6363
#18 "main.mld"
64-
let x = 5
64+
let five = 5
6565
#25 "main.mld"
6666

67-
let y = x + 6. (* This is a typing error *)
67+
let y = five +. five (* This is a typing error *)
6868

6969

7070
We can output to a file
7171

7272
$ odoc extract-code --line-directives --name error.ml -o error.ml main.mld
7373
$ cat error.ml
7474
#18 "main.mld"
75-
let x = 5
75+
let five = 5
7676
#25 "main.mld"
7777

78-
let y = x + 6. (* This is a typing error *)
78+
let y = five +. five (* This is a typing error *)
7979

8080

81-
Let's check line directive work ("-color always" to make sure the error message
82-
is the same in all context):
81+
Let's check line directive work (we only look at the location to avoid ocaml
82+
version-dependent output):
8383

84-
$ ocaml -color always error.ml
85-
File "main.mld", line 26, characters 15-17:
86-
Error: This expression has type float but an expression was expected of type
87-
int
84+
$ ocaml error.ml 2> error.txt
8885
[2]
86+
$ grep File error.txt
87+
File "main.mld", line 26, characters 11-15:
8988

90-
Here is the line 26, and the characters 15-17:
89+
Here is the line 26, and the characters 11-15:
9190

9291
$ sed -n '26p' main.mld
93-
let y = x + 6. (* This is a typing error *)
94-
$ sed -n '26p' main.mld | cut -c15-17
95-
6.
92+
let y = five +. five (* This is a typing error *)
93+
$ sed -n '26p' main.mld | cut -c11-15
94+
five
95+
96+
"five" has type int and should have type float.

0 commit comments

Comments
 (0)