2017-04-09 10:36:14 -07:00
|
|
|
'use strict';
|
2017-06-27 06:00:35 +02:00
|
|
|
|
2018-01-28 12:07:18 +01:00
|
|
|
require('../common');
|
2017-04-09 10:36:14 -07:00
|
|
|
const assert = require('assert');
|
|
|
|
|
2017-06-27 06:00:35 +02:00
|
|
|
// No args
|
2017-04-09 10:36:14 -07:00
|
|
|
assert.throws(
|
|
|
|
() => { assert.fail(); },
|
2018-01-28 12:07:18 +01:00
|
|
|
{
|
2017-04-25 13:18:25 -07:00
|
|
|
code: 'ERR_ASSERTION',
|
2018-01-28 12:07:18 +01:00
|
|
|
name: 'AssertionError [ERR_ASSERTION]',
|
2017-06-27 06:00:35 +02:00
|
|
|
message: 'Failed',
|
|
|
|
operator: undefined,
|
|
|
|
actual: undefined,
|
|
|
|
expected: undefined
|
2018-01-28 12:07:18 +01:00
|
|
|
}
|
2017-04-09 10:36:14 -07:00
|
|
|
);
|
|
|
|
|
2017-06-27 06:00:35 +02:00
|
|
|
// One arg = message
|
2018-01-28 12:07:18 +01:00
|
|
|
assert.throws(() => {
|
2017-07-05 12:05:24 -04:00
|
|
|
assert.fail('custom message');
|
|
|
|
}, {
|
|
|
|
code: 'ERR_ASSERTION',
|
2018-01-28 12:07:18 +01:00
|
|
|
name: 'AssertionError [ERR_ASSERTION]',
|
2017-07-05 12:05:24 -04:00
|
|
|
message: 'custom message',
|
|
|
|
operator: undefined,
|
|
|
|
actual: undefined,
|
|
|
|
expected: undefined
|
|
|
|
});
|
2017-04-09 10:36:14 -07:00
|
|
|
|
2017-09-09 20:36:47 -05:00
|
|
|
// One arg = Error
|
2018-01-28 12:07:18 +01:00
|
|
|
assert.throws(() => {
|
2017-09-09 20:36:47 -05:00
|
|
|
assert.fail(new TypeError('custom message'));
|
|
|
|
}, {
|
2018-01-28 12:07:18 +01:00
|
|
|
name: 'TypeError',
|
2017-09-09 20:36:47 -05:00
|
|
|
message: 'custom message',
|
|
|
|
operator: undefined,
|
|
|
|
actual: undefined,
|
|
|
|
expected: undefined
|
|
|
|
});
|