|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var Mt = require("./mt.js"); |
| 4 | +var Block = require("../../lib/js/block.js"); |
| 5 | +var Curry = require("../../lib/js/curry.js"); |
| 6 | +var Format = require("../../lib/js/format.js"); |
| 7 | +var Printexc = require("../../lib/js/printexc.js"); |
| 8 | +var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); |
| 9 | + |
| 10 | +var suites = [/* [] */0]; |
| 11 | + |
| 12 | +var test_id = [0]; |
| 13 | + |
| 14 | +function eq(loc, x, y) { |
| 15 | + test_id[0] = test_id[0] + 1 | 0; |
| 16 | + suites[0] = /* :: */[ |
| 17 | + /* tuple */[ |
| 18 | + loc + (" id " + test_id[0]), |
| 19 | + function () { |
| 20 | + return /* Eq */Block.__(0, [ |
| 21 | + x, |
| 22 | + y |
| 23 | + ]); |
| 24 | + } |
| 25 | + ], |
| 26 | + suites[0] |
| 27 | + ]; |
| 28 | + return /* () */0; |
| 29 | +} |
| 30 | + |
| 31 | +var Hi = Caml_exceptions.create("Exception_repr_test.Hi"); |
| 32 | + |
| 33 | +var Hello = Caml_exceptions.create("Exception_repr_test.Hello"); |
| 34 | + |
| 35 | +var A = Caml_exceptions.create("Exception_repr_test.A"); |
| 36 | + |
| 37 | +Printexc.register_printer(function (param) { |
| 38 | + if (param === Hi) { |
| 39 | + return /* Some */["hey"]; |
| 40 | + } else if (param[0] === A) { |
| 41 | + return /* Some */[Curry._1(Format.asprintf(/* Format */[ |
| 42 | + /* String_literal */Block.__(11, [ |
| 43 | + "A(", |
| 44 | + /* Int */Block.__(4, [ |
| 45 | + /* Int_d */0, |
| 46 | + /* No_padding */0, |
| 47 | + /* No_precision */0, |
| 48 | + /* Char_literal */Block.__(12, [ |
| 49 | + /* ")" */41, |
| 50 | + /* End_of_format */0 |
| 51 | + ]) |
| 52 | + ]) |
| 53 | + ]), |
| 54 | + "A(%d)" |
| 55 | + ]), param[1])]; |
| 56 | + } else { |
| 57 | + return /* None */0; |
| 58 | + } |
| 59 | + }); |
| 60 | + |
| 61 | +eq("File \"exception_repr_test.ml\", line 22, characters 7-14", "hey", Printexc.to_string(Hi)); |
| 62 | + |
| 63 | +eq("File \"exception_repr_test.ml\", line 23, characters 7-14", "A(1)", Printexc.to_string([ |
| 64 | + A, |
| 65 | + 1 |
| 66 | + ])); |
| 67 | + |
| 68 | +eq("File \"exception_repr_test.ml\", line 24, characters 7-14", "Exception_repr_test.Hello", Printexc.to_string(Hello)); |
| 69 | + |
| 70 | +Mt.from_pair_suites("exception_repr_test.ml", suites[0]); |
| 71 | + |
| 72 | +exports.suites = suites; |
| 73 | +exports.test_id = test_id; |
| 74 | +exports.eq = eq; |
| 75 | +exports.Hi = Hi; |
| 76 | +exports.Hello = Hello; |
| 77 | +exports.A = A; |
| 78 | +/* Not a pure module */ |
0 commit comments