forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexn_error_pattern.js
84 lines (65 loc) · 2.26 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
'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");
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
function f(match) {
if (Caml_exceptions.caml_is_extension(match)) {
if (match === Caml_builtin_exceptions.not_found) {
return 0;
} else if (match[0] === Caml_builtin_exceptions.invalid_argument || match === Caml_builtin_exceptions.stack_overflow) {
return 1;
} else if (match[0] === Caml_builtin_exceptions.sys_error) {
return 2;
} else {
return undefined;
}
}
}
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 === Caml_builtin_exceptions.not_found || match[0] === Caml_builtin_exceptions.invalid_argument) {
return 0;
} else if (match[0] === Caml_builtin_exceptions.sys_error) {
return 2;
} else if (match[0] === A || match[0] === B) {
return match[1];
} else {
return undefined;
}
}
}
var suites = /* record */[/* contents : [] */0];
var test_id = /* record */[/* contents */0];
function eq(loc, x, y) {
return Mt.eq_suites(test_id, suites, loc, x, y);
}
eq("File \"test/exn_error_pattern.ml\", line 34, characters 5-12", f(Caml_builtin_exceptions.not_found), 0);
eq("File \"test/exn_error_pattern.ml\", line 35, characters 5-12", f([
Caml_builtin_exceptions.invalid_argument,
""
]), 1);
eq("File \"test/exn_error_pattern.ml\", line 36, characters 5-12", f(Caml_builtin_exceptions.stack_overflow), 1);
eq("File \"test/exn_error_pattern.ml\", line 37, characters 5-12", f([
Caml_builtin_exceptions.sys_error,
""
]), 2);
var tmp;
try {
throw new Error("x");
}
catch (raw_e){
tmp = Caml_js_exceptions.internalToOCamlException(raw_e);
}
eq("File \"test/exn_error_pattern.ml\", line 38, characters 5-12", f(tmp), undefined);
Mt.from_pair_suites("Exn_error_pattern", suites[0]);
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 */