Skip to content

Commit 530e63a

Browse files
Trotttargos
authored andcommitted
assert: remove unreachable code
In lib/internal/assert/assertion_error.js, line 391 assures that `operator` is 'deepEqual' so there is no need to check the value of `operator` in a ternary on the next line (line 392). Remove the ternary. PR-URL: #27786 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d774ea5 commit 530e63a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎lib/internal/assert/assertion_error.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ class AssertionError extends Error{
374374
}else{
375375
letres=inspectValue(actual);
376376
letother=inspectValue(expected);
377-
constknownOperators=kReadableOperator[operator];
377+
constknownOperator=kReadableOperator[operator];
378378
if(operator==='notDeepEqual'&&res===other){
379-
res=`${knownOperators}\n\n${res}`;
379+
res=`${knownOperator}\n\n${res}`;
380380
if(res.length>1024){
381381
res=`${res.slice(0,1021)}...`;
382382
}
@@ -389,8 +389,7 @@ class AssertionError extends Error{
389389
other=`${other.slice(0,509)}...`;
390390
}
391391
if(operator==='deepEqual'){
392-
consteq=operator==='deepEqual' ? 'deep-equal' : 'equal';
393-
res=`${knownOperators}\n\n${res}\n\nshould loosely ${eq}\n\n`;
392+
res=`${knownOperator}\n\n${res}\n\nshould loosely deep-equal\n\n`;
394393
}else{
395394
constnewOperator=kReadableOperator[`${operator}Unequal`];
396395
if(newOperator){

0 commit comments

Comments
(0)