New issue
Advanced search Search tips

Issue 702708 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Apr 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 672152



Sign in to add a comment

Audit support for own_property, inherits, readonly?

Project Member Reported by rtoy@chromium.org, Mar 17 2017

Issue description

Currently, if we want to use Audit to test properties or inheritance, we have to do that ourselves.  However testharness has assert_own_property, assert_inherits, and assert_readonly.  Perhaps we should add equivalents to Audit?

Also, testharness has assert_throws which might be good for should.throw()
 
https://darobin.github.io/test-harness-tutorial/docs/using-testharness.html

According to this documentation (not sure about its current status), testharness has the following assertion primitives:

assert_true
assert_false
assert_equals
assert_not_equals
assert_in_array
assert_array_equals
assert_approx_equals
assert_regexp_match
assert_own_property
assert_inherits
assert_readonly
assert_throws
assert_unreached

Why own_property, inherits, readonly deserve its place in Audit? I think it should be all or nothing. By minimizing the surface of testharness in Audit, we will have a better independency. If you think their primitives are better, we should adapt Audit - but then it will cause another set of issues: we have to update Audit and expected files every time testharness updates theirs.

Using true/false assertion only seems to be the most efficient (and future-proof) from my perspective. If you think we need more granularity in assertion types, I can certainly add our own.

Comment 2 by rtoy@chromium.org, Mar 30 2017

We have equivalents for true, false, equals, not_equals, in_array (sort of?), array_equals, approx_equals, and throws.

I don't expect we need regexp_match or unreached.  That leaves just own_property, inherits, readonly.  These are just convenience functions so I don't have to remember how to test own_property, inherits, and readonly.

Okay then. I will add our own version of assertions for own_property, inherits, and readonly.
rtoy@

Do you have any test that can use these new feature? I can include those changes in the CL.
rtoy@ I am looking at how these assertions are implemented in testharness:

* readonly: This literally tries to overwrite the data and see if the value is changed. The comment on
  the code also warns about the side effect of this check. I rather not have this in Audit.

* own_property:
  should('propertyName').beOwnPropertyOf(Object);

* inherits: I think we are more interested in the relationship between class. So I think we want to have:
  should(ChildObject).beInheritedFrom(ParentClassName);

Comment 6 by rtoy@chromium.org, Apr 6 2017

audio-scheduled-source-basic.html uses hasOwnProperty.

Not having readonly is not a big deal, especially given how it's currently implemented in testharness.

The other ideas look fine.
Status: Verified (was: Assigned)

Sign in to add a comment