-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathformat_test.js
209 lines (167 loc) · 5.33 KB
/
format_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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
var Mt = require("./mt.js");
var List = require("../../lib/js/list.js");
var Bytes = require("../../lib/js/bytes.js");
var Pervasives = require("../../lib/js/pervasives.js");
var Caml_format = require("../../lib/js/caml_format.js");
var suites = {
contents: /* [] */0
};
var test_id = {
contents: 0
};
function eq(loc, x, y) {
test_id.contents = test_id.contents + 1 | 0;
suites.contents = {
hd: [
loc + (" id " + String(test_id.contents)),
(function (param) {
return {
TAG: "Eq",
_0: x,
_1: y
};
})
],
tl: suites.contents
};
}
function eq3(loc, a, b, c) {
eq(loc, a, b);
eq(loc, b, c);
eq(loc, a, c);
}
var M = {};
eq("File \"format_test.res\", line 23, characters 5-12", 7.875, 7.875);
eq("File \"format_test.res\", line 25, characters 5-12", -7.875, -7.875);
eq3("File \"format_test.res\", line 29, characters 6-13", Infinity, Number.POSITIVE_INFINITY, Pervasives.infinity);
eq3("File \"format_test.res\", line 30, characters 6-13", -Infinity, Number.NEGATIVE_INFINITY, Pervasives.neg_infinity);
eq3("File \"format_test.res\", line 31, characters 6-13", Pervasives.max_float, 1.79769313486231571e+308, Number.MAX_VALUE);
eq("File \"format_test.res\", line 32, characters 5-12", Pervasives.classify_float(Infinity), "FP_infinite");
eq("File \"format_test.res\", line 33, characters 5-12", Pervasives.classify_float(Infinity), "FP_infinite");
eq("File \"format_test.res\", line 35, characters 5-12", Pervasives.min_float, 2.22507385850720138e-308);
eq("File \"format_test.res\", line 36, characters 5-12", Pervasives.epsilon_float, 2.22044604925031308e-16);
eq("File \"format_test.res\", line 37, characters 5-12", 4.94065645841e-324, 5e-324);
eq("File \"format_test.res\", line 38, characters 5-12", 1.00000000000000022 - 1, Pervasives.epsilon_float);
eq("File \"format_test.res\", line 39, characters 5-12", 1.11253692925360069e-308 / 2.22507385850720138e-308, 0.5);
eq("File \"format_test.res\", line 40, characters 5-12", Pervasives.classify_float(1.11253692925360069e-308), "FP_subnormal");
eq("File \"format_test.res\", line 41, characters 5-12", 1.11253692925360069e-308, 1.11253692925360069e-308);
eq("File \"format_test.res\", line 42, characters 5-12", 2.22507385850720138e-308, 2.22507385850720138e-308);
eq("File \"format_test.res\", line 44, characters 5-12", (1 + 255 / 256) * 8, 15.96875);
eq("File \"format_test.res\", line 45, characters 5-12", (1 + 4095 / 4096) * 8, 15.998046875);
eq("File \"format_test.res\", line 46, characters 5-12", (1 + 65535 / 65536) * 8, 15.9998779296875);
function f(loc, ls) {
List.iter((function (param) {
eq(loc, Caml_format.float_of_string(param[0]), param[1]);
}), ls);
}
f("File \"format_test.res\", line 53, characters 11-18", {
hd: [
"0x3.fp+1",
7.875
],
tl: {
hd: [
" 0x3.fp2",
15.75
],
tl: {
hd: [
" 0x4.fp2",
19.75
],
tl: /* [] */0
}
}
});
function sl(f) {
return Caml_format.hexstring_of_float(f, -1, /* '-' */45);
}
function aux_list(loc, ls) {
List.iter((function (param) {
eq(loc, Caml_format.hexstring_of_float(param[0], -1, /* '-' */45), param[1]);
}), ls);
}
var literals_0 = [
7.875,
"0x1.f8p+2"
];
var literals_1 = {
hd: [
0.3,
"0x1.3333333333333p-2"
],
tl: {
hd: [
Pervasives.infinity,
"infinity"
],
tl: {
hd: [
0.4,
"0x1.999999999999ap-2"
],
tl: {
hd: [
0.5,
"0x1p-1"
],
tl: {
hd: [
0.6,
"0x1.3333333333333p-1"
],
tl: {
hd: [
0.7,
"0x1.6666666666666p-1"
],
tl: {
hd: [
0.8,
"0x1.999999999999ap-1"
],
tl: {
hd: [
0.9,
"0x1.ccccccccccccdp-1"
],
tl: /* [] */0
}
}
}
}
}
}
}
};
var literals = {
hd: literals_0,
tl: literals_1
};
aux_list("File \"format_test.res\", line 72, characters 18-25", literals);
var s = Caml_format.hexstring_of_float(7.875, -1, /* '-' */45);
eq("File \"format_test.res\", line 74, characters 12-19", Bytes.unsafe_to_string(Bytes.uppercase_ascii(Bytes.unsafe_of_string(s))), "0X1.F8P+2");
function scan_float(loc, s, expect) {
eq(loc, Caml_format.float_of_string(s), expect);
}
scan_float("File \"format_test.res\", line 80, characters 13-20", "0x3f.p1", 126);
scan_float("File \"format_test.res\", line 81, characters 13-20", "0x1.3333333333333p-2", 0.3);
List.iter((function (param) {
scan_float("File \"format_test.res\", line 82, characters 35-42", param[1], param[0]);
}), literals);
var f1 = - -9.9;
eq("File \"format_test.res\", line 88, characters 5-12", f1, 9.9);
Mt.from_pair_suites("Format_test", suites.contents);
exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
exports.eq3 = eq3;
exports.M = M;
exports.f = f;
exports.sl = sl;
exports.aux_list = aux_list;
exports.literals = literals;
exports.scan_float = scan_float;
/* Not a pure module */