mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
848 B
30 lines
848 B
/* eslint-disable required-modules */
|
|
'use strict';
|
|
|
|
const assert = require('assert');
|
|
|
|
// https://github.com/w3c/testharness.js/blob/master/testharness.js
|
|
module.exports = {
|
|
test: (fn, desc) => {
|
|
try {
|
|
fn();
|
|
} catch (err) {
|
|
console.error(`In ${desc}:`);
|
|
throw err;
|
|
}
|
|
},
|
|
assert_equals: assert.strictEqual,
|
|
assert_true: (value, message) => assert.strictEqual(value, true, message),
|
|
assert_false: (value, message) => assert.strictEqual(value, false, message),
|
|
assert_throws: (code, func, desc) => {
|
|
assert.throws(func, function(err) {
|
|
return typeof err === 'object' &&
|
|
'name' in err &&
|
|
err.name.startsWith(code.name);
|
|
}, desc);
|
|
},
|
|
assert_array_equals: assert.deepStrictEqual,
|
|
assert_unreached(desc) {
|
|
assert.fail(`Reached unreachable code: ${desc}`);
|
|
}
|
|
};
|
|
|