forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexn_error_pattern.js
91 lines (72 loc) · 2.05 KB
/
exn_error_pattern.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
'use strict';
var Mt = require("./mt.js");
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
var Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js");
function f(match) {
if (Caml_exceptions.caml_is_extension(match)) {
if (match.RE_EXN_ID === "Not_found") {
return 0;
} else if (match.RE_EXN_ID === "Invalid_argument" || match.RE_EXN_ID === "Stack_overflow") {
return 1;
} else if (match.RE_EXN_ID === "Sys_error") {
return 2;
} else {
return ;
}
}
}
var A = Caml_exceptions.create("Exn_error_pattern.A");
var B = Caml_exceptions.create("Exn_error_pattern.B");
function g(match) {
if (Caml_exceptions.caml_is_extension(match)) {
if (match.RE_EXN_ID === "Not_found" || match.RE_EXN_ID === "Invalid_argument") {
return 0;
} else if (match.RE_EXN_ID === "Sys_error") {
return 2;
} else if (match.RE_EXN_ID === A || match.RE_EXN_ID === B) {
return match._1;
} else {
return ;
}
}
}
var suites = {
contents: /* [] */0
};
var test_id = {
contents: 0
};
function eq(loc, x, y) {
return Mt.eq_suites(test_id, suites, loc, x, y);
}
eq("File \"exn_error_pattern.ml\", line 34, characters 5-12", f({
RE_EXN_ID: "Not_found"
}), 0);
eq("File \"exn_error_pattern.ml\", line 35, characters 5-12", f({
RE_EXN_ID: "Invalid_argument",
_1: ""
}), 1);
eq("File \"exn_error_pattern.ml\", line 36, characters 5-12", f({
RE_EXN_ID: "Stack_overflow"
}), 1);
eq("File \"exn_error_pattern.ml\", line 37, characters 5-12", f({
RE_EXN_ID: "Sys_error",
_1: ""
}), 2);
var tmp;
try {
throw new Error("x");
}
catch (raw_e){
tmp = Caml_js_exceptions.internalToOCamlException(raw_e);
}
eq("File \"exn_error_pattern.ml\", line 38, characters 5-12", f(tmp), undefined);
Mt.from_pair_suites("Exn_error_pattern", suites.contents);
exports.f = f;
exports.A = A;
exports.B = B;
exports.g = g;
exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
/* Not a pure module */