Skip to content

Commit

Permalink
[testharness.js][docs] Improve and document assert_object_equals (web…
Browse files Browse the repository at this point in the history
  • Loading branch information
zcorpan authored and Luke Bjerring committed Jun 26, 2018
1 parent 669ff59 commit 33d59c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/_writing-tests/testharness-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,11 @@ Relies on `===`, distinguishes between `-0` and `+0`, and has a specific check f
asserts that `expected` is an Array, and `actual` is equal to one of the
members i.e. `expected.indexOf(actual) != -1`
### `assert_object_equals(actual, expected, description)`
asserts that `actual` is an object and not null and that all enumerable
properties on `actual` are own properties on `expected` with the same values,
recursing if the value is an object and not null.
### `assert_array_equals(actual, expected, description)`
asserts that `actual` and `expected` have the same
length and the value of each indexed property in `actual` is the strictly equal
Expand Down
3 changes: 3 additions & 0 deletions resources/testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,9 @@ policies and contribution forms [3].

function assert_object_equals(actual, expected, description)
{
assert(typeof actual === "object" && actual !== null, "assert_object_equals", description,
"value is ${actual}, expected object",
{actual: actual});
//This needs to be improved a great deal
function check_equal(actual, expected, stack)
{
Expand Down

0 comments on commit 33d59c0

Please sign in to comment.