Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed Jun 21, 2016
1 parent e868d6b commit 3b6e32b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
12 changes: 8 additions & 4 deletions jscomp/test/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ caml_format_test.cmj : ../stdlib/printf.cmi mt.cmi ../stdlib/int64.cmi \
../stdlib/format.cmi ../stdlib/buffer.cmi ../stdlib/array.cmi
caml_format_test.cmx : ../stdlib/printf.cmx mt.cmx ../stdlib/int64.cmx \
../stdlib/format.cmx ../stdlib/buffer.cmx ../stdlib/array.cmx
chain_code_test.cmj : ../runtime/js.cmj
chain_code_test.cmx : ../runtime/js.cmx
chain_code_test.cmj : mt.cmi ../runtime/js.cmj
chain_code_test.cmx : mt.cmx ../runtime/js.cmx
class3_test.cmj : mt.cmi ../stdlib/list.cmi ../runtime/js.cmj \
../stdlib/array.cmi
class3_test.cmx : mt.cmx ../stdlib/list.cmx ../runtime/js.cmx \
Expand Down Expand Up @@ -388,6 +388,8 @@ printf_sim.cmj : ../stdlib/printf.cmi
printf_sim.cmx : ../stdlib/printf.cmx
printf_test.cmj : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi
printf_test.cmx : ../stdlib/printf.cmx mt.cmx ../stdlib/format.cmx
promise.cmj : ../runtime/js.cmj
promise.cmx : ../runtime/js.cmx
qcc.cmj : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \
../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \
../stdlib/array.cmi
Expand Down Expand Up @@ -752,8 +754,8 @@ caml_format_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/int64.cmi \
../stdlib/format.cmi ../stdlib/buffer.cmi ../stdlib/array.cmi
caml_format_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/int64.cmj \
../stdlib/format.cmj ../stdlib/buffer.cmj ../stdlib/array.cmj
chain_code_test.cmo : ../runtime/js.cmo
chain_code_test.cmj : ../runtime/js.cmj
chain_code_test.cmo : mt.cmi ../runtime/js.cmo
chain_code_test.cmj : mt.cmj ../runtime/js.cmj
class3_test.cmo : mt.cmi ../stdlib/list.cmi ../runtime/js.cmo \
../stdlib/array.cmi
class3_test.cmj : mt.cmj ../stdlib/list.cmj ../runtime/js.cmj \
Expand Down Expand Up @@ -1058,6 +1060,8 @@ printf_sim.cmo : ../stdlib/printf.cmi
printf_sim.cmj : ../stdlib/printf.cmj
printf_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi
printf_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/format.cmj
promise.cmo : ../runtime/js.cmo
promise.cmj : ../runtime/js.cmj
qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \
../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \
../stdlib/array.cmi
Expand Down
10 changes: 10 additions & 0 deletions jscomp/test/chain_code_test.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
let suites : Mt.pair_suites ref = ref []
let test_id = ref 0
let eq loc x y =
incr test_id ;
suites :=
(loc ^" id " ^ (string_of_int !test_id), (fun _ -> Mt.Eq(x,y))) :: !suites

let f h =
let open Js.Unsafe in
!(!(!h#x)#y)#z
Expand All @@ -16,4 +23,7 @@ let f4 h x y =
(* h##(draw (x,y)) *)
(* ##(draw (x,y)) *)
(* ##(draw(x,y)) *)
let () =
eq __LOC__ 32 (f2 ({ x = {y = {z = 32}}} [@bs.obj]))

let () = Mt.from_pair_suites __FILE__ !suites
48 changes: 42 additions & 6 deletions lib/js/test/chain_code_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
'use strict';

var Mt = require("./mt");
var Block = require("../block");

var suites = [/* [] */0];

var test_id = [0];

function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
function () {
return /* Eq */Block.__(0, [
x,
y
]);
}
],
suites[0]
];
return /* () */0;
}

function f(h) {
return h.x.y.z;
Expand All @@ -26,8 +49,21 @@ function f4(h, x, y) {
];
}

exports.f = f;
exports.f2 = f2;
exports.f3 = f3;
exports.f4 = f4;
/* No side effect */
eq('File "chain_code_test.ml", line 27, characters 5-12', 32, f2({
x: {
y: {
z: 32
}
}
}));

Mt.from_pair_suites("chain_code_test.ml", suites[0]);

exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
exports.f = f;
exports.f2 = f2;
exports.f3 = f3;
exports.f4 = f4;
/* Not a pure module */
2 changes: 1 addition & 1 deletion lib/js/test/gpr_459_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
'use strict';

var Mt = require("./mt");
Expand Down

0 comments on commit 3b6e32b

Please sign in to comment.