Skip to content

Commit dab3d01

Browse files
lib: add getActual as priivate method to Assert class
1 parent e83ea62 commit dab3d01

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/assert.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ class Assert {
364364
return NO_EXCEPTION_SENTINEL;
365365
}
366366

367+
#getActual(fn) {
368+
validateFunction(fn, 'fn');
369+
try {
370+
fn();
371+
} catch (e) {
372+
return e;
373+
}
374+
return NO_EXCEPTION_SENTINEL;
375+
}
376+
367377
/**
368378
* Pure assertion tests whether a value is truthy, as determined
369379
* by !!value.
@@ -662,7 +672,7 @@ class Assert {
662672
* @returns {void}
663673
*/
664674
throws(promiseFn, ...args) {
665-
this.#expectsError(Assert.prototype.throws, getActual(promiseFn), ...args);
675+
this.#expectsError(Assert.prototype.throws, this.#getActual(promiseFn), ...args);
666676
};
667677

668678
/**
@@ -682,7 +692,7 @@ class Assert {
682692
* @returns {void}
683693
*/
684694
doesNotThrow(fn, ...args) {
685-
this.#expectsNoError(Assert.prototype.doesNotThrow, getActual(fn), ...args);
695+
this.#expectsNoError(Assert.prototype.doesNotThrow, this.#getActual(fn), ...args);
686696
};
687697

688698
/**
@@ -798,16 +808,6 @@ class Comparison {
798808
}
799809
}
800810

801-
function getActual(fn) {
802-
validateFunction(fn, 'fn');
803-
try {
804-
fn();
805-
} catch (e) {
806-
return e;
807-
}
808-
return NO_EXCEPTION_SENTINEL;
809-
}
810-
811811
function checkIsPromise(obj) {
812812
// Accept native ES6 promises and promises that are implemented in a similar
813813
// way. Do not accept thenables that use a function as `obj` and that have no

0 commit comments

Comments
 (0)