Skip to content

Commit bb6de97

Browse files
committed
Merge pull request #326 from ocsigen/camlp4_test_fix
Fix syntax extension tests.
2 parents 47305ae + 3ad0748 commit bb6de97

File tree

7 files changed

+55
-93
lines changed

7 files changed

+55
-93
lines changed

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ clean:
3636
rm -f camlp4/*.cm[io] camlp4/*.result
3737

3838
ppx/%.result: ppx/%.ml
39-
TERM=dumb ocaml -noprompt -I ../lib -ppx ../lib/ppx/ppx_js < $< | tail -n +2 > $@
39+
TERM=dumb ocaml -noinit -noprompt -I ../lib -ppx ../lib/ppx/ppx_js < $< | tail -n +2 > $@
4040

4141
ppx/test_%: ppx/%.result ppx/%.expected
4242
diff $?

tests/camlp4/meth.expected

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11

22
Characters 40-43:
3-
fun (obj : int) -> obj##m
3+
fun (obj : int) -> obj##m();;
44
^^^
55
Error: This expression has type int but an expression was expected of type
6-
< .. > Js.t
6+
'a Js.t
77
Characters 25-28:
8-
fun (obj : < > Js.t) -> obj##m
8+
fun (obj : < > Js.t) -> obj##m();;
99
^^^
1010
Error: This expression has type < >
1111
It has no method m
1212
Characters 43-49:
13-
fun (obj : < m : float Js.prop > Js.t) -> obj##m
13+
fun (obj : < m : float Js.prop > Js.t) -> obj##m();;
1414
^^^^^^
1515
Error: This expression has type
1616
float Js.prop = < get : float; set : float -> unit > Js.gen_prop
17-
but an expression was expected of type 'jsoo_32b5ee21 Js.meth
18-
Characters 43-49:
19-
fun (obj : < m : float Js.meth > Js.t) -> obj##m + 1
20-
^^^^^^
17+
but an expression was expected of type 'a Js.meth
18+
Characters 43-51:
19+
fun (obj : < m : float Js.meth > Js.t) -> obj##m() + 1;;
20+
^^^^^^^^
2121
Error: This expression has type float but an expression was expected of type
2222
int
2323
Characters 48-54:
24-
fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m + 1
24+
fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m() + 1;;
2525
^^^^^^
2626
Error: This expression has type int -> int Js.meth
27-
but an expression was expected of type 'jsoo_32b5ee21 Js.meth
27+
but an expression was expected of type 'a Js.meth
2828
Characters 41-47:
29-
fun (obj : < m : int Js.meth > Js.t) -> obj##m 1
29+
fun (obj : < m : int Js.meth > Js.t) -> obj##m(1);;
3030
^^^^^^
3131
Error: This expression has type int Js.meth
32-
but an expression was expected of type
33-
'jsoo_173316d7 -> 'jsoo_29529091 Js.meth
34-
Characters 50-58:
35-
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m 1 + 1
36-
^^^^^^^^
32+
but an expression was expected of type 'a -> 'b Js.meth
33+
Characters 50-59:
34+
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;
35+
^^^^^^^^^
3736
Error: This expression has type float but an expression was expected of type
3837
int
3938

tests/camlp4/meth.ml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
21
(* Test methods. *)
32

4-
let x1 = fun (obj : int) -> obj##m();;
3+
fun (obj : int) -> obj##m();;
54

6-
let _ = 3;; let _ = 3;;
5+
fun (obj : < > Js.t) -> obj##m();;
76

8-
let x2 = fun (obj : < > Js.t) -> obj##m();;
7+
fun (obj : < m : float Js.prop > Js.t) -> obj##m();;
98

10-
let _ = 3;; let _ = 3;;
9+
fun (obj : < m : float Js.meth > Js.t) -> obj##m() + 1;;
1110

12-
let x3 = fun (obj : < m : float Js.prop > Js.t) -> obj##m();;
11+
fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m() + 1;;
1312

14-
let _ = 3;; let _ = 3;;
13+
fun (obj : < m : int Js.meth > Js.t) -> obj##m(1);;
1514

16-
let x4 = fun (obj : < m : float Js.meth > Js.t) -> obj##m() + 1;;
17-
18-
let _ = 3;; let _ = 3;;
19-
20-
let x5 = fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m() + 1;;
21-
22-
let _ = 3;; let _ = 3;;
23-
24-
let x6 = fun (obj : < m : int Js.meth > Js.t) -> obj##m(1);;
25-
26-
let _ = 3;; let _ = 3;;
27-
28-
let x7 = fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;
29-
30-
let _ = 3;; let _ = 3;;
15+
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;

tests/camlp4/prop.expected

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11

22
Characters 45-48:
3-
fun (obj : int) -> obj##.p
3+
fun (obj : int) -> obj##p;;
44
^^^
55
Error: This expression has type int but an expression was expected of type
6-
< .. > Js.t
6+
'a Js.t
77
Characters 25-28:
8-
fun (obj : < > Js.t) -> obj##.p
8+
fun (obj : < > Js.t) -> obj##p;;
99
^^^
1010
Error: This expression has type < >
1111
It has no method p
12-
Characters 53-60:
13-
fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##.p + 1
14-
^^^^^^^
12+
Characters 53-59:
13+
fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##p + 1;;
14+
^^^^^^
1515
Error: This expression has type
1616
float Js.writeonly_prop = < set : float -> unit > Js.gen_prop
17-
but an expression was expected of type
18-
< get : 'jsoo_res; .. > Js.gen_prop
17+
but an expression was expected of type < get : 'a; .. > Js.gen_prop
1918
The first object type has no method get
20-
Characters 43-50:
21-
fun (obj : < p : float Js.prop > Js.t) -> obj##.p + 1
22-
^^^^^^^
19+
Characters 43-49:
20+
fun (obj : < p : float Js.prop > Js.t) -> obj##p + 1;;
21+
^^^^^^
2322
Error: This expression has type float but an expression was expected of type
2423
int
2524

tests/camlp4/prop.ml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
21
(* Test prop reading. *)
32

4-
let x1 = fun (obj : int) -> obj##p;;
3+
fun (obj : int) -> obj##p;;
54

6-
let _ = 3;; let _ = 3;;
5+
fun (obj : < > Js.t) -> obj##p;;
76

8-
let x2 = fun (obj : < > Js.t) -> obj##p;;
9-
10-
let _ = 3;; let _ = 3;;
11-
12-
let x3 = fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##p + 1;;
13-
14-
let _ = 3;; let _ = 3;;
15-
16-
let x4 = fun (obj : < p : float Js.prop > Js.t) -> obj##p + 1;;
17-
18-
let _ = 3;; let _ = 3;;
7+
fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##p + 1;;
198

9+
fun (obj : < p : float Js.prop > Js.t) -> obj##p + 1;;

tests/camlp4/write_prop.expected

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11

22
Characters 45-48:
3-
fun (obj : int) -> obj##.p := 2
3+
fun (obj : int) -> obj##p <- 2;;
44
^^^
55
Error: This expression has type int but an expression was expected of type
6-
< .. > Js.t
6+
'a Js.t
77
Characters 25-28:
8-
fun (obj : < > Js.t) -> obj##.p := 2
8+
fun (obj : < > Js.t) -> obj##p <- 2;;
99
^^^
1010
Error: This expression has type < >
1111
It has no method p
12-
Characters 52-59:
13-
fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##.p := 1
14-
^^^^^^^
12+
Characters 52-58:
13+
fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##p <- 1;;
14+
^^^^^^
1515
Error: This expression has type
1616
float Js.readonly_prop = < get : float > Js.gen_prop
1717
but an expression was expected of type
18-
< set : 'jsoo_arg -> unit; .. > Js.gen_prop
18+
< set : 'a -> unit; .. > Js.gen_prop
1919
The first object type has no method set
20-
Characters 54-55:
21-
fun (obj : < p : float Js.prop > Js.t) -> obj##.p := 1
22-
^
20+
Characters 53-54:
21+
fun (obj : < p : float Js.prop > Js.t) -> obj##p <- 1;;
22+
^
2323
Error: This expression has type int but an expression was expected of type
2424
float
25-
Characters 41-55:
26-
fun (obj : < p : int Js.prop > Js.t) -> (obj##.p := 1) + 1
27-
^^^^^^^^^^^^^^
25+
Characters 42-53:
26+
fun (obj : < p : int Js.prop > Js.t) -> (obj##p <- 1) + 1;;
27+
^^^^^^^^^^^
2828
Error: This expression has type unit but an expression was expected of type
2929
int
3030

tests/camlp4/write_prop.ml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
21
(* Test prop writing. *)
32

4-
let x1 = fun (obj : int) -> obj##p <- 2;;
3+
fun (obj : int) -> obj##p <- 2;;
54

6-
let _ = 3;; let _ = 3;;
5+
fun (obj : < > Js.t) -> obj##p <- 2;;
76

8-
let x2 = fun (obj : < > Js.t) -> obj##p <- 2;;
7+
fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##p <- 1;;
98

10-
let _ = 3;; let _ = 3;;
9+
fun (obj : < p : float Js.prop > Js.t) -> obj##p <- 1;;
1110

12-
let x3 = fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##p <- 1;;
13-
14-
let _ = 3;; let _ = 3;;
15-
16-
let x4 = fun (obj : < p : float Js.prop > Js.t) -> obj##p <- 1;;
17-
18-
let _ = 3;; let _ = 3;;
19-
20-
let x5 = fun (obj : < p : int Js.prop > Js.t) -> (obj##p <- 1) + 1;;
21-
22-
let _ = 3;; let _ = 3;;
11+
fun (obj : < p : int Js.prop > Js.t) -> (obj##p <- 1) + 1;;

0 commit comments

Comments
 (0)