Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ clean:
rm -f camlp4/*.cm[io] camlp4/*.result

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

ppx/test_%: ppx/%.result ppx/%.expected
diff $?
Expand Down
31 changes: 15 additions & 16 deletions tests/camlp4/meth.expected
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@

Characters 40-43:
fun (obj : int) -> obj##m
fun (obj : int) -> obj##m();;
^^^
Error: This expression has type int but an expression was expected of type
< .. > Js.t
'a Js.t
Characters 25-28:
fun (obj : < > Js.t) -> obj##m
fun (obj : < > Js.t) -> obj##m();;
^^^
Error: This expression has type < >
It has no method m
Characters 43-49:
fun (obj : < m : float Js.prop > Js.t) -> obj##m
fun (obj : < m : float Js.prop > Js.t) -> obj##m();;
^^^^^^
Error: This expression has type
float Js.prop = < get : float; set : float -> unit > Js.gen_prop
but an expression was expected of type 'jsoo_32b5ee21 Js.meth
Characters 43-49:
fun (obj : < m : float Js.meth > Js.t) -> obj##m + 1
^^^^^^
but an expression was expected of type 'a Js.meth
Characters 43-51:
fun (obj : < m : float Js.meth > Js.t) -> obj##m() + 1;;
^^^^^^^^
Error: This expression has type float but an expression was expected of type
int
Characters 48-54:
fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m + 1
fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m() + 1;;
^^^^^^
Error: This expression has type int -> int Js.meth
but an expression was expected of type 'jsoo_32b5ee21 Js.meth
but an expression was expected of type 'a Js.meth
Characters 41-47:
fun (obj : < m : int Js.meth > Js.t) -> obj##m 1
fun (obj : < m : int Js.meth > Js.t) -> obj##m(1);;
^^^^^^
Error: This expression has type int Js.meth
but an expression was expected of type
'jsoo_173316d7 -> 'jsoo_29529091 Js.meth
Characters 50-58:
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m 1 + 1
^^^^^^^^
but an expression was expected of type 'a -> 'b Js.meth
Characters 50-59:
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;
^^^^^^^^^
Error: This expression has type float but an expression was expected of type
int

29 changes: 7 additions & 22 deletions tests/camlp4/meth.ml
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
(* Test methods. *)

let x1 = fun (obj : int) -> obj##m();;
fun (obj : int) -> obj##m();;

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

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

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

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

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

let x4 = fun (obj : < m : float Js.meth > Js.t) -> obj##m() + 1;;

let _ = 3;; let _ = 3;;

let x5 = fun (obj : < m : int -> int Js.meth > Js.t) -> obj##m() + 1;;

let _ = 3;; let _ = 3;;

let x6 = fun (obj : < m : int Js.meth > Js.t) -> obj##m(1);;

let _ = 3;; let _ = 3;;

let x7 = fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;

let _ = 3;; let _ = 3;;
fun (obj : < m : int -> float Js.meth > Js.t) -> obj##m(1) + 1;;
21 changes: 10 additions & 11 deletions tests/camlp4/prop.expected
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@

Characters 45-48:
fun (obj : int) -> obj##.p
fun (obj : int) -> obj##p;;
^^^
Error: This expression has type int but an expression was expected of type
< .. > Js.t
'a Js.t
Characters 25-28:
fun (obj : < > Js.t) -> obj##.p
fun (obj : < > Js.t) -> obj##p;;
^^^
Error: This expression has type < >
It has no method p
Characters 53-60:
fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##.p + 1
^^^^^^^
Characters 53-59:
fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##p + 1;;
^^^^^^
Error: This expression has type
float Js.writeonly_prop = < set : float -> unit > Js.gen_prop
but an expression was expected of type
< get : 'jsoo_res; .. > Js.gen_prop
but an expression was expected of type < get : 'a; .. > Js.gen_prop
The first object type has no method get
Characters 43-50:
fun (obj : < p : float Js.prop > Js.t) -> obj##.p + 1
^^^^^^^
Characters 43-49:
fun (obj : < p : float Js.prop > Js.t) -> obj##p + 1;;
^^^^^^
Error: This expression has type float but an expression was expected of type
int

18 changes: 4 additions & 14 deletions tests/camlp4/prop.ml
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
(* Test prop reading. *)

let x1 = fun (obj : int) -> obj##p;;
fun (obj : int) -> obj##p;;

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

let x2 = fun (obj : < > Js.t) -> obj##p;;

let _ = 3;; let _ = 3;;

let x3 = fun (obj : < p : float Js.writeonly_prop > Js.t) -> obj##p + 1;;

let _ = 3;; let _ = 3;;

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

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

fun (obj : < p : float Js.prop > Js.t) -> obj##p + 1;;
26 changes: 13 additions & 13 deletions tests/camlp4/write_prop.expected
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@

Characters 45-48:
fun (obj : int) -> obj##.p := 2
fun (obj : int) -> obj##p <- 2;;
^^^
Error: This expression has type int but an expression was expected of type
< .. > Js.t
'a Js.t
Characters 25-28:
fun (obj : < > Js.t) -> obj##.p := 2
fun (obj : < > Js.t) -> obj##p <- 2;;
^^^
Error: This expression has type < >
It has no method p
Characters 52-59:
fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##.p := 1
^^^^^^^
Characters 52-58:
fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##p <- 1;;
^^^^^^
Error: This expression has type
float Js.readonly_prop = < get : float > Js.gen_prop
but an expression was expected of type
< set : 'jsoo_arg -> unit; .. > Js.gen_prop
< set : 'a -> unit; .. > Js.gen_prop
The first object type has no method set
Characters 54-55:
fun (obj : < p : float Js.prop > Js.t) -> obj##.p := 1
^
Characters 53-54:
fun (obj : < p : float Js.prop > Js.t) -> obj##p <- 1;;
^
Error: This expression has type int but an expression was expected of type
float
Characters 41-55:
fun (obj : < p : int Js.prop > Js.t) -> (obj##.p := 1) + 1
^^^^^^^^^^^^^^
Characters 42-53:
fun (obj : < p : int Js.prop > Js.t) -> (obj##p <- 1) + 1;;
^^^^^^^^^^^
Error: This expression has type unit but an expression was expected of type
int

21 changes: 5 additions & 16 deletions tests/camlp4/write_prop.ml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
(* dummy "let _ = 3" are to work arround ... camlp4 weirdness I guess *)
(* Test prop writing. *)

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

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

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

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

let x3 = fun (obj : < p : float Js.readonly_prop > Js.t) -> obj##p <- 1;;

let _ = 3;; let _ = 3;;

let x4 = fun (obj : < p : float Js.prop > Js.t) -> obj##p <- 1;;

let _ = 3;; let _ = 3;;

let x5 = fun (obj : < p : int Js.prop > Js.t) -> (obj##p <- 1) + 1;;

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