-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathexception_value_test.js
90 lines (78 loc) · 1.84 KB
/
exception_value_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
'use strict';
var Curry = require("../../lib/js/curry.js");
var Js_exn = require("../../lib/js/js_exn.js");
var Js_primitive = require("../../lib/js/js_primitive.js");
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
function f() {
throw Caml_builtin_exceptions.not_found;
}
function assert_f(x) {
if (x <= 3) {
throw [
Caml_builtin_exceptions.assert_failure,
[
"exception_value_test.ml",
9,
12
]
];
}
return 3;
}
function hh() {
throw Caml_builtin_exceptions.not_found;
}
var A = Caml_exceptions.create("Exception_value_test.A");
var B = Caml_exceptions.create("Exception_value_test.B");
var C = Caml_exceptions.create("Exception_value_test.C");
var u = [
A,
3
];
function test_not_found(f, _) {
try {
return Curry._1(f, /* () */0);
}
catch (exn){
if (exn === Caml_builtin_exceptions.not_found) {
return 2;
} else {
throw exn;
}
}
}
function test_js_error2() {
try {
return JSON.parse(" {\"x\" : }");
}
catch (raw_e){
var e = Js_exn.internalToOCamlException(raw_e);
if (e[0] === Js_exn.$$Error) {
console.log(Js_primitive.undefined_to_opt(e[1].stack));
throw e;
} else {
throw e;
}
}
}
function test_js_error3() {
try {
JSON.parse(" {\"x\"}");
return 1;
}
catch (e){
return 0;
}
}
exports.f = f;
exports.assert_f = assert_f;
exports.hh = hh;
exports.A = A;
exports.B = B;
exports.C = C;
exports.u = u;
exports.test_not_found = test_not_found;
exports.test_js_error2 = test_js_error2;
exports.test_js_error3 = test_js_error3;
/* No side effect */