-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathTest.mjs
54 lines (49 loc) · 1.61 KB
/
Test.mjs
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
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Fs from "fs";
import * as Path from "path";
import * as Util from "util";
import * as Curry from "rescript/lib/es6/curry.js";
import * as Core__Option from "../src/Core__Option.mjs";
import * as CodeFrame from "@babel/code-frame";
var dirname = (new URL('.', import.meta.url).pathname);
function print(value) {
var match = typeof value;
if (match === "object" || match === "bigint") {
return Util.inspect(value);
} else if (match === "string") {
return Core__Option.getExn(JSON.stringify(value));
} else {
return String(value);
}
}
function run(loc, left, comparator, right) {
if (Curry._2(comparator, left, right)) {
return ;
}
var match = loc[0];
var line = match[1];
var file = match[0];
var fileContent = Fs.readFileSync(Path.join(dirname, file), {
encoding: "utf-8"
});
var left$1 = print(left);
var right$1 = print(right);
var codeFrame = CodeFrame.codeFrameColumns(fileContent, {
start: {
line: line
}
}, {
highlightCode: true
});
var errorMessage = "\r\n \u001b[31mTest Failure!\r\n \u001b[36m" + file + "\u001b[0m:\u001b[2m" + String(line) + "\r\n" + codeFrame + "\r\n \u001b[39mLeft: \u001b[31m" + left$1 + "\r\n \u001b[39mRight: \u001b[31m" + right$1 + "\u001b[0m\r\n";
console.log(errorMessage);
var obj = {};
Error.captureStackTrace(obj);
console.log(obj.stack.replace(/\n /g, "\n ").replace(/^Error\n/, "").replace(/^.+\n/, "").replace(/\n at .+\(node:internal.+\n?/g, ""));
}
export {
dirname ,
print ,
run ,
}
/* dirname Not a pure module */