-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathrecursive_records_test.js
123 lines (94 loc) · 2.71 KB
/
recursive_records_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
var Mt = require("./mt.js");
var List = require("../../lib/js/list.js");
var Caml_obj = require("../../lib/js/caml_obj.js");
var suites = {
contents: /* [] */0
};
var test_id = {
contents: 0
};
function eq(loc, x, y) {
Mt.eq_suites(test_id, suites, loc, x, y);
}
var rec_cell = {};
rec_cell.content = 3;
rec_cell.next = rec_cell;
function f0(x) {
var rec_cell = {};
Caml_obj.update_dummy(rec_cell, {
content: Math.imul(x, x) - 6 | 0,
next: rec_cell
});
return rec_cell;
}
function a0(x) {
return (x.content + x.next.content | 0) + x.next.next.content | 0;
}
eq("File \"recursive_records_test.res\", line 26, characters 5-12", a0(rec_cell), 9);
eq("File \"recursive_records_test.res\", line 27, characters 5-12", a0(f0(3)), 9);
var rec_cell2 = {};
rec_cell2.content = 3;
rec_cell2.next = rec_cell2;
function f2(x) {
var rec_cell2 = {};
Caml_obj.update_dummy(rec_cell2, {
TAG: "Cons",
content: Math.imul(x, x) - 6 | 0,
next: rec_cell2
});
return rec_cell2;
}
function hd(x) {
if (typeof x !== "object") {
return 0;
} else {
return x.content;
}
}
function tl_exn(x) {
if (typeof x === "object") {
return x.next;
}
throw {
RE_EXN_ID: "Assert_failure",
_1: [
"recursive_records_test.res",
49,
11
],
Error: new Error()
};
}
eq("File \"recursive_records_test.res\", line 54, characters 5-12", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9);
var rec_cell2$1 = f2(3);
eq("File \"recursive_records_test.res\", line 56, characters 5-12", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9);
var rec_cell3 = {};
rec_cell3.hd = 3;
rec_cell3.tl = rec_cell3;
function f3(x) {
var rec_cell3 = {};
Caml_obj.update_dummy(rec_cell3, {
hd: Math.imul(x, x) - 6 | 0,
tl: rec_cell3
});
return rec_cell3;
}
eq("File \"recursive_records_test.res\", line 68, characters 4-11", (List.hd(rec_cell3) + List.hd(List.tl(rec_cell3)) | 0) + List.hd(List.tl(List.tl(rec_cell3))) | 0, 9);
var rec_cell3$1 = f3(3);
eq("File \"recursive_records_test.res\", line 77, characters 4-11", (List.hd(rec_cell3$1) + List.hd(List.tl(rec_cell3$1)) | 0) + List.hd(List.tl(List.tl(rec_cell3$1))) | 0, 9);
Mt.from_pair_suites("recursive_records_test.res", suites.contents);
exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
exports.rec_cell = rec_cell;
exports.f0 = f0;
exports.a0 = a0;
exports.rec_cell2 = rec_cell2;
exports.f2 = f2;
exports.hd = hd;
exports.tl_exn = tl_exn;
exports.rec_cell3 = rec_cell3;
exports.f3 = f3;
/* Not a pure module */