• Home
  • Raw
  • Download

Lines Matching refs:assert

26 const assert = require('assert');  constant
30 const a = assert;
42 assert.ok(a.AssertionError.prototype instanceof Error,
45 assert.throws(() => a(false), a.AssertionError, 'ok(false)');
46 assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)');
52 assert.ok(false, new Error('ok(false)'));
55 assert.ok(e instanceof Error);
57 assert.ok(threw, 'Error: ok(false)');
66 assert.throws(() => a.equal(true, false),
76 assert.throws(() => a.notEqual(true, true),
79 assert.throws(() => a.strictEqual(2, '2'),
83 assert.throws(() => a.strictEqual(null, undefined),
86 assert.throws(
94 assert.throws(
103 assert.throws(
119 assert.throws(() => thrower(a.AssertionError), a.AssertionError, 'message');
120 assert.throws(() => thrower(a.AssertionError), a.AssertionError);
121 assert.throws(() => thrower(a.AssertionError));
124 assert.throws(() => thrower(TypeError));
127 assert.throws(
148 assert.ok(e instanceof TypeError);
150 assert(threw, 'a.doesNotThrow with an explicit error is eating extra errors');
160 assert.ok(e instanceof a.AssertionError);
161 assert.ok(!e.stack.includes('at Function.doesNotThrow'));
163 assert.ok(threw, 'a.doesNotThrow is not catching type matching errors');
166 assert.throws(
177 assert.throws(
185 assert.throws(
200 assert.throws(
209 assert.ok(threw, 'wrong constructor validation');
245 assert.throws(
250 assert.throws(() => {
256 assert.strictEqual(
261 assert.strictEqual(err.actual, actual);
270 assert.throws(
280 assert.throws(
289 assert.throws(
298 assert.throws(
312 assert.ok(e instanceof a.AssertionError);
313 assert.ok(!e.stack.includes('at Function.throws'));
315 assert.ok(threw);
322 assert.throws(
323 () => assert.strictEqual(actual, ''),
364 assert.throws(
365 () => assert.strictEqual(1, 2),
372 assert.throws(
373 () => assert.strictEqual(1, 2, 'oh no'),
386 assert.strictEqual(1, 2, rangeError);
388 assert.strictEqual(e, rangeError);
390 assert.ok(e instanceof RangeError, 'Incorrect error type thrown');
392 assert.ok(threw);
402 assert.ok(e.message.includes(rangeError.message));
403 assert.ok(e instanceof assert.AssertionError);
404 assert.ok(!e.stack.includes('doesNotThrow'), e);
406 assert.ok(threw);
412 assert.throws(
423 testBlockTypeError(assert.throws, 'string');
424 testBlockTypeError(assert.doesNotThrow, 'string');
425 testBlockTypeError(assert.throws, 1);
426 testBlockTypeError(assert.doesNotThrow, 1);
427 testBlockTypeError(assert.throws, true);
428 testBlockTypeError(assert.doesNotThrow, true);
429 testBlockTypeError(assert.throws, false);
430 testBlockTypeError(assert.doesNotThrow, false);
431 testBlockTypeError(assert.throws, []);
432 testBlockTypeError(assert.doesNotThrow, []);
433 testBlockTypeError(assert.throws, {});
434 testBlockTypeError(assert.doesNotThrow, {});
435 testBlockTypeError(assert.throws, /foo/);
436 testBlockTypeError(assert.doesNotThrow, /foo/);
437 testBlockTypeError(assert.throws, null);
438 testBlockTypeError(assert.doesNotThrow, null);
439 testBlockTypeError(assert.throws, undefined);
440 testBlockTypeError(assert.doesNotThrow, undefined);
445 assert.throws(() => { throw 'error'; }, (err) => err === 'error');
446 assert.throws(() => { throw new Error(); }, (err) => err instanceof Error);
449 assert.throws(() => {
450 assert.strictEqual('A'.repeat(1000), '');
452 assert.strictEqual(err.code, 'ERR_ASSERTION');
453 assert.strictEqual(err.message,
456 assert.strictEqual(err.actual.length, 1000);
457 assert.ok(inspect(err).includes(`actual: '${'A'.repeat(488)}...'`));
464 assert.throws(() => {
465 assert.strictEqual(multilineString, '');
467 assert.strictEqual(err.code, 'ERR_ASSERTION');
468 assert.strictEqual(err.message.split('\n').length, 19);
469 assert.strictEqual(err.actual.split('\n').length, 16);
470 assert.ok(inspect(err).includes(
482 assert.throws(
483 () => new assert.AssertionError(input),
493 assert.throws(
494 () => assert.strictEqual(new Error('foo'), new Error('foobar')),
513 const assert = require('assert').strict; constant
515 assert.throws(() => assert.equal(1, true), assert.AssertionError);
516 assert.notEqual(0, false);
517 assert.throws(() => assert.deepEqual(1, true), assert.AssertionError);
518 assert.notDeepEqual(0, false);
519 assert.equal(assert.strict, assert.strict.strict);
520 assert.equal(assert.equal, assert.strictEqual);
521 assert.equal(assert.deepEqual, assert.deepStrictEqual);
522 assert.equal(assert.notEqual, assert.notStrictEqual);
523 assert.equal(assert.notDeepEqual, assert.notDeepStrictEqual);
524 assert.equal(Object.keys(assert).length, Object.keys(a).length);
525 assert(7);
526 assert.throws(
527 () => assert(...[]),
534 assert.throws(
545 assert.throws(
547 assert.ok(
553 constructor: assert.AssertionError,
577 assert.throws(
578 () => assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]),
597 assert.throws(
598 () => assert.deepEqual(
618 assert.throws(
619 () => assert.deepEqual(
639 assert.throws(
640 () => assert.deepEqual(
656 assert.throws(
657 () => assert.deepEqual([1, 2, 1], undefined),
670 assert.throws(
671 () => assert.deepEqual([1, 2, 1], [2, 1]),
682 assert.throws(
683 () => assert.deepEqual(Array(28).fill(1), Array(28).fill(2)),
690 assert.throws(() => assert.deepEqual(obj1, obj2), {
702 assert.throws(
703 () => assert.notDeepEqual([1], [1]),
713 assert.throws(
714 () => assert.notDeepEqual(data, data),
719 assert.throws(
720 () => assert.ok(null),
723 constructor: assert.AssertionError,
729 assert.throws(
730 () => assert(typeof 123n === 'string'),
733 constructor: assert.AssertionError,
740 assert.throws(
741 () => assert(false, Symbol('foo')),
744 constructor: assert.AssertionError,
756 assert(
760 assert.throws(
764 constructor: assert.AssertionError,
769 assert.throws(
773 constructor: assert.AssertionError,
781 assert.throws(
793 constructor: assert.AssertionError,
805 assert.throws(
817 constructor: assert.AssertionError,
830 assert.throws(() => {
838 constructor: assert.AssertionError,
849 assert.throws(
851 assert(true); assert(null, undefined);
855 constructor: assert.AssertionError,
861 assert.throws(
863 assert
868 constructor: assert.AssertionError,
874 assert.throws(
876 () => assert['ok']["apply"](null, [0]),
879 constructor: assert.AssertionError,
885 assert.throws(
888 wrapper(assert, false);
892 constructor: assert.AssertionError,
897 assert.throws(
898 () => assert.ok.call(null, 0),
901 constructor: assert.AssertionError,
908 assert.throws(
909 () => assert.ok.call(null, 0, 'test'),
912 constructor: assert.AssertionError,
919 assert.throws(
920 () => new Function('assert', 'assert(1 === 2);')(assert),
923 constructor: assert.AssertionError,
927 assert.throws(
935 assert.throws(
936 () => assert.throws(() => {}, 'Error message', 'message'),
951 assert.throws(
952 () => assert.throws(() => {}, input),
964 assert.throws(() => {
965 assert.ok((() => Boolean('' === false))());
980 assert.throws(errFn, errObj);
983 assert.throws(errFn, errObj);
988 assert.throws(
989 () => assert.throws(errFn, errObj),
1005 assert.throws(
1006 () => assert.throws(errFn, errObj),
1021 assert.throws(
1022 () => assert.throws(() => { throw new Error(); }, { foo: 'bar' }, 'foobar'),
1024 constructor: assert.AssertionError,
1030 assert.throws(
1040 assert.throws(() => { throw new Error('e'); }, new Error('e'));
1041 assert.throws(
1042 () => assert.throws(() => { throw new TypeError('e'); }, new Error('e')),
1054 assert.throws(
1055 () => assert.throws(() => { throw new Error('foo'); }, new Error('')),
1070 assert.throws(() => { throw undefined; }, /undefined/);
1071 assert.throws(
1082 assert.throws(
1083 () => assert.throws(() => { throw new Error(); }, {}),
1090 assert.throws(
1103 assert.throws(
1118 assert.throws(() => { throw null; }, 'foo');
1120 assert.throws(
1121 () => assert.strictEqual([], []),
1129 assert.throws(
1130 () => assert.strictEqual(args, { 0: 'a' }),
1139 assert.throws(
1147 assert.throws(
1148 () => assert.throws(
1168 assert.throws(
1169 () => assert.throws(
1188 assert.throws(
1189 () => assert.throws(
1204 assert.throws(
1205 () => assert.strictEqual('test test', 'test foobar'),
1218 assert.throws(
1221 assert.notStrictEqual(obj, obj);
1230 assert.throws(
1233 assert.notStrictEqual(obj, obj);
1246 assert.deepStrictEqual(Array(100).fill(1), 'foobar');
1249 assert(/actual: \[Array],\n expected: 'foobar',/.test(inspect(err)));
1251 assert(threw);
1254 assert.throws(
1259 assert.throws(
1264 assert.throws(
1269 assert.throws(
1274 assert.throws(
1279 assert.throws(
1284 assert.throws(
1289 assert.throws(
1294 assert.throws(
1299 assert.throws(
1307 const err = new assert.AssertionError({
1312 const err2 = new assert.AssertionError({
1317 assert(!err.stack.includes('hidden'));
1318 assert(!err2.stack.includes('hidden'));
1322 assert.throws(
1323 () => assert.throws(() => { throw Symbol('foo'); }, RangeError),
1330 assert.throws(
1332 () => assert.throws(() => { throw [1, 2]; }, RangeError),
1342 assert.throws(
1343 () => assert.throws(() => { throw err; }, validate),
1357 assert.throws(
1362 assert.throws(() => { throw err; }, RangeError);
1373 assert.throws(
1374 () => assert.match(/abc/, 'string'),
1381 assert.throws(
1382 () => assert.match('string', /abc/),
1392 assert.throws(
1393 () => assert.match('string', /abc/, 'foobar'),
1403 assert.throws(
1404 () => assert.match('string', /abc/, errorMessage),
1407 assert.throws(
1408 () => assert.match({ abc: 123 }, /abc/),
1418 assert.match('I will pass', /pass$/);
1423 assert.throws(
1424 () => assert.doesNotMatch(/abc/, 'string'),
1431 assert.throws(
1432 () => assert.doesNotMatch('string', /string/),
1442 assert.throws(
1443 () => assert.doesNotMatch('string', /string/, 'foobar'),
1453 assert.throws(
1454 () => assert.doesNotMatch('string', /string/, errorMessage),
1457 assert.throws(
1458 () => assert.doesNotMatch({ abc: 123 }, /abc/),
1468 assert.doesNotMatch('I will pass', /different$/);
1473 assert.throws(() => {
1476 assert.strictEqual(111554n, 11111115);
1478 assert.strictEqual(inspect(err).split('\n')[5], ' ^');