| 458 | } |
| 459 | } |
| 460 | function assertEquals(actual, expected, msg) { |
| 461 | if (equal(actual, expected)) { |
| 462 | return; |
| 463 | } |
| 464 | let message = ""; |
| 465 | const actualString = format(actual); |
| 466 | const expectedString = format(expected); |
| 467 | try { |
| 468 | const stringDiff = typeof actual === "string" && typeof expected === "string"; |
| 469 | const diffResult = stringDiff ? diffstr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n")); |
| 470 | const diffMsg = buildMessage(diffResult, { |
| 471 | stringDiff |
| 472 | }).join("\n"); |
| 473 | message = `Values are not equal:\n${diffMsg}`; |
| 474 | } catch { |
| 475 | message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`; |
| 476 | } |
| 477 | if (msg) { |
| 478 | message = msg; |
| 479 | } |
| 480 | throw new AssertionError(message); |
| 481 | } |
| 482 | function assertNotEquals(actual, expected, msg) { |
| 483 | if (!equal(actual, expected)) { |
| 484 | return; |