-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
54 lines (48 loc) · 1.13 KB
/
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
"use strict";
//@ts-ignore
require("./");
var fs = require("fs");
fs.readFile("--doesntexist--", "utf8", noop);
console.info("PASS: noop exists globally and... wait for it... does nothing");
fs.promises
.readFile("--doesntexist--", "utf8")
.catch(throwop)
.catch(function (err) {
if (!(err instanceof Error)) {
throw new Error("throwop didn't throw!");
}
})
//@ts-ignore
.then(throwop)
.catch(throwop)
.catch(function (err) {
throw new Error("throwop threw... nothing! why!?");
});
console.info("PASS: throwop throws errors (but not false-y things)");
/** @type {?any} */
var bomb = {};
doop(
/**
* @param {string} bar
* @param {string} baz
*/
function (bar, baz) {
//@ts-ignore
var me = this;
if (me !== bomb || "bar" !== bar || "baz" !== baz) {
throw new Error(
"doop didn't apply thisness / didn't have the right args"
);
}
bomb = null;
console.info(
"PASS: doop calls the first arg, if it's a function, with thisness and args"
);
},
["bar", "baz"],
bomb
);
if (bomb) {
throw new Error("doop didn't disarm the bomb");
}
console.info("PASS");