assert: fix rejects stack trace and operator · nodejs/node@75463a9 (original) (raw)

`@@ -502,7 +502,7 @@ class Comparison {

`

502

502

`}

`

503

503

`}

`

504

504

``

505

``

`-

function compareExceptionKey(actual, expected, key, message, keys) {

`

``

505

`+

function compareExceptionKey(actual, expected, key, message, keys, fn) {

`

506

506

`if (!(key in actual) || !isDeepStrictEqual(actual[key], expected[key])) {

`

507

507

`if (!message) {

`

508

508

`// Create placeholder objects to create a nice output.

`

`@@ -513,24 +513,24 @@ function compareExceptionKey(actual, expected, key, message, keys) {

`

513

513

`actual: a,

`

514

514

`expected: b,

`

515

515

`operator: 'deepStrictEqual',

`

516

``

`-

stackStartFn: assert.throws

`

``

516

`+

stackStartFn: fn

`

517

517

`});

`

518

518

`err.actual = actual;

`

519

519

`err.expected = expected;

`

520

``

`-

err.operator = 'throws';

`

``

520

`+

err.operator = fn.name;

`

521

521

`throw err;

`

522

522

`}

`

523

523

`innerFail({

`

524

524

` actual,

`

525

525

` expected,

`

526

526

` message,

`

527

``

`-

operator: 'throws',

`

528

``

`-

stackStartFn: assert.throws

`

``

527

`+

operator: fn.name,

`

``

528

`+

stackStartFn: fn

`

529

529

`});

`

530

530

`}

`

531

531

`}

`

532

532

``

533

``

`-

function expectedException(actual, expected, msg) {

`

``

533

`+

function expectedException(actual, expected, msg, fn) {

`

534

534

`if (typeof expected !== 'function') {

`

535

535

`if (isRegExp(expected))

`

536

536

`return expected.test(actual);

`

`@@ -548,9 +548,9 @@ function expectedException(actual, expected, msg) {

`

548

548

` expected,

`

549

549

`message: msg,

`

550

550

`operator: 'deepStrictEqual',

`

551

``

`-

stackStartFn: assert.throws

`

``

551

`+

stackStartFn: fn

`

552

552

`});

`

553

``

`-

err.operator = 'throws';

`

``

553

`+

err.operator = fn.name;

`

554

554

`throw err;

`

555

555

`}

`

556

556

``

`@@ -570,7 +570,7 @@ function expectedException(actual, expected, msg) {

`

570

570

`expected[key].test(actual[key])) {

`

571

571

`continue;

`

572

572

`}

`

573

``

`-

compareExceptionKey(actual, expected, key, msg, keys);

`

``

573

`+

compareExceptionKey(actual, expected, key, msg, keys, fn);

`

574

574

`}

`

575

575

`return true;

`

576

576

`}

`

`@@ -676,7 +676,7 @@ function expectsError(stackStartFn, actual, error, message) {

`

676

676

` stackStartFn

`

677

677

`});

`

678

678

`}

`

679

``

`-

if (error && expectedException(actual, error, message) === false) {

`

``

679

`+

if (error && !expectedException(actual, error, message, stackStartFn)) {

`

680

680

`throw actual;

`

681

681

`}

`

682

682

`}

`