forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathint_overflow_test.js
151 lines (146 loc) · 4.19 KB
/
int_overflow_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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Generated CODE, PLEASE EDIT WITH CARE
'use strict';
var Mt = require("./mt");
var Int32 = require("../stdlib/int32");
var Caml_primitive = require("../runtime/caml_primitive");
function hash_variant(s) {
var accu = 0;
for(var i = 0 ,i_finish = s.length - 1; i<= i_finish; ++i){
accu = Caml_primitive.imul(223, accu) + s.charCodeAt(i) & (1 << 31) - 1;
}
if (accu > 1073741823) {
return accu - (1 << 31) | 0;
}
else {
return accu;
}
}
function fib(n) {
if (n !== 0 && n !== 1) {
return fib(n - 1 | 0) + fib(n - 2 | 0) | 0;
}
else {
return 1;
}
}
Mt.from_pair_suites("int_overflow_test.ml", /* :: */[
/* tuple */[
"plus_overflow",
function () {
return /* Eq */{
0: /* true */1,
1: +((Int32.max_int + 1 | 0) === Int32.min_int),
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"minus_overflow",
function () {
return /* Eq */{
0: /* true */1,
1: +((Int32.min_int - Int32.one | 0) === Int32.max_int),
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"flow_again",
function () {
return /* Eq */{
0: 2147483646,
1: (Int32.max_int + Int32.max_int | 0) + Int32.min_int | 0,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"flow_again",
function () {
return /* Eq */{
0: -2,
1: Int32.max_int + Int32.max_int | 0,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"hash_test",
function () {
return /* Eq */{
0: hash_variant("xxyyzzuuxxzzyy00112233"),
1: 544087776,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"hash_test2",
function () {
return /* Eq */{
0: hash_variant("xxyyzxzzyy"),
1: -449896130,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"int_literal_flow",
function () {
return /* Eq */{
0: -1,
1: -1,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"int_literal_flow2",
function () {
return /* Eq */{
0: -1,
1: -1,
length: 2,
tag: 0
};
}
],
/* :: */[
/* tuple */[
"int_literal_flow3",
function () {
return /* Eq */{
0: -1,
1: -1,
length: 2,
tag: 0
};
}
],
/* [] */0
]
]
]
]
]
]
]
]
]);
exports.hash_variant = hash_variant;
exports.fib = fib;
/* Not a pure module */