* Assert that ``actual`` is the same value as ``expected``. * * For objects this compares by object identity; for primitives * this distinguishes between 0 and -0, and has correct handling * of NaN. * * @param {Any} actual - Test value. * @param {Any} expected - Ex
(actual, expected, description)
| 1584 | * @param {string} [description] - Description of the condition being tested. |
| 1585 | */ |
| 1586 | function assert_equals(actual, expected, description) |
| 1587 | { |
| 1588 | /* |
| 1589 | * Test if two primitives are equal or two objects |
| 1590 | * are the same object |
| 1591 | */ |
| 1592 | if (typeof actual != typeof expected) { |
| 1593 | assert(false, "assert_equals", description, |
| 1594 | "expected (" + typeof expected + ") ${expected} but got (" + typeof actual + ") ${actual}", |
| 1595 | {expected:expected, actual:actual}); |
| 1596 | return; |
| 1597 | } |
| 1598 | assert(same_value(actual, expected), "assert_equals", description, |
| 1599 | "expected ${expected} but got ${actual}", |
| 1600 | {expected:expected, actual:actual}); |
| 1601 | } |
| 1602 | expose_assert(assert_equals, "assert_equals"); |
| 1603 | |
| 1604 | /** |
no test coverage detected
searching dependent graphs…