Skip to content

docs: Add example for “sequential” testing #116

@Zearin

Description

@Zearin

Note about this Issue’s title: I don’t think “sequential” is the right word, but it’s the closest I can think of at the moment.


I’m trying to learn hTest by rewriting some tests for DOMRect as specified in the WPT.

Here’s some of those tests (viewable in the link ↑). It demonstrates the “sequential” problem I’m having with the rewrite:

var r = new DOMRect()

r.x = 5
assert_equals(r.x, 5, 'Expected value for x is 5')
assert_equals(r.left, 5, 'Expected value for left is 5')
assert_equals(r.right, 5, 'Expected value for right is 5')

r.y = 5
assert_equals(r.y, 5, 'Expected value for y is 5')
assert_equals(r.top, 5, 'Expected value for top is 5')
assert_equals(r.bottom, 5, 'Expected value for bottom is 5')

r.width = 5
assert_equals(r.width, 5, 'Expected value for width is 5')
assert_equals(r.left, 5, 'Expected value for left is 5')
assert_equals(r.right, 10, 'Expected value for right is 10')

r.height = 5
assert_equals(r.height, 5, 'Expected value for height is 5')
assert_equals(r.top, 5, 'Expected value for top is 5')
assert_equals(r.bottom, 10, 'Expected value for bottom is 10')

In the above, it’s easy to rewrite the tests for x and y for hTest in isolation:

  1. Set someAttribute to a value
  2. Check that someAttribute, and its dependents, are equal to the same value

But by the time the tests arrive at width, there’s a problem. This test suite is manipulating a single DOMRect instance. That means that the tests for width are expecting x and y to be 5 (which is why they expect r.right to equal 10).

(That’s what I’m trying to describe when I said “sequential” in the Issue title. hTest’s tests arrays are also “sequential” because, um, they are arrays…but they’re also isolated. Each test in tests is not modifying the result of the previous test.)

How would you rewrite this kind of test structure in hTest?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions