While we're at it, use assert() instead of assert.sameValue() for brevity,
if we are not specifically testing that the return value of hasOwnProperty
is the value true or false; and add more informative assertion messages to
help with debugging.
In some cases, the Object.hasOwnProperty.call could be replaced with
verifyProperty(), if the property descriptor was also being verified at
the same time.
This fixes some tests that were faulty to begin with: a common mistake was
Object.hasOwnProperty(obj, prop) which is probably going to return false
when that's not what you want.
The only instances left of `Object.hasOwnProperty` are one regression test
in implementation-contributed which I can't tell if it was intentionally
needed to trigger the regression, and a few instances of
`Object.hasOwnProperty('prototype')` which would defeat the purpose to
convert into `Object.prototype.hasOwnProperty.call(Object, 'prototype')`
form.
Closes: #3524
Includes key should use flow notation to be able parsed easier
as suggested in https://github.com/tc39/test262/issues/1997
Added this check to the linting script and updated tests accordingly.
A number of tests were found to be duplicative based on an analysis of
file contents (included below). Eliminate the duplication by removing
the version of each test with less precise metadata. In cases where this
removal could technically be considered a reduction in coverage,
preserve the verification of additional semantics in the remaining test.
$ git grep -El 'new\s+\w+.prototype' | sed 's/[^\/]\+$//g' | sort | uniq -c | grep -vE '^\s+1 ' | awk '{print $2}' | xargs grep -Elr 'new\s+\w+.prototype'
test/built-ins/Array/prototype/join/S15.4.4.5_A6.7.js
test/built-ins/Array/prototype/join/not-a-constructor.js
test/built-ins/Array/prototype/pop/not-a-constructor.js
test/built-ins/Array/prototype/pop/S15.4.4.6_A5.7.js
test/built-ins/Array/prototype/push/S15.4.4.7_A6.7.js
test/built-ins/Array/prototype/push/not-a-constructor.js
test/built-ins/Array/prototype/shift/not-a-constructor.js
test/built-ins/Array/prototype/shift/S15.4.4.9_A5.7.js
test/built-ins/Array/prototype/slice/not-a-constructor.js
test/built-ins/Array/prototype/slice/S15.4.4.10_A5.7.js
test/built-ins/Array/prototype/sort/not-a-constructor.js
test/built-ins/Array/prototype/sort/S15.4.4.11_A7.7.js
test/built-ins/Array/prototype/splice/S15.4.4.12_A5.7.js
test/built-ins/Array/prototype/splice/not-a-constructor.js
test/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A4.7.js
test/built-ins/Array/prototype/toLocaleString/not-a-constructor.js
test/built-ins/Array/prototype/toString/S15.4.4.2_A4.7.js
test/built-ins/Array/prototype/toString/not-a-constructor.js
test/built-ins/Array/prototype/unshift/S15.4.4.13_A5.7.js
test/built-ins/Array/prototype/unshift/not-a-constructor.js
test/built-ins/Function/prototype/apply/S15.3.4.3_A8_T1.js
test/built-ins/Function/prototype/apply/S15.3.4.3_A8_T2.js
test/built-ins/Function/prototype/apply/not-a-constructor.js
test/built-ins/Function/prototype/call/not-a-constructor.js
test/built-ins/Function/prototype/call/S15.3.4.4_A7_T2.js
test/built-ins/Function/prototype/call/S15.3.4.4_A7_T1.js
test/built-ins/Function/prototype/toString/S15.3.4.2_A7.js
test/built-ins/Function/prototype/toString/not-a-constructor.js
test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A7.js
test/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js
test/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js
test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A7.js
test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A7.js
test/built-ins/Object/prototype/toLocaleString/not-a-constructor.js
test/built-ins/Object/prototype/toString/not-a-constructor.js
test/built-ins/Object/prototype/toString/not-ctor.js
test/built-ins/Object/prototype/valueOf/not-a-constructor.js
test/built-ins/Object/prototype/valueOf/S15.2.4.4_A7.js
The `arrayContains` function has a number of deficiencies which make it
inappropriate for Test262:
- It apparently isn't very useful: despite being available for over 7
years, fewer than ten tests use it
- It's misleading: its documentation reads, "Verify that a subArray is
contained within an array." In reality, it only verifies that all the
elements of one array are present in another--order does not matter.
- It's not ergonomic for test authors: it has been misused to create
tests that were prone to false positives [1]
- It's not ergonomic for implementers: ostensibly designed for use with
`assert`, the failure messages produced by tests that use it do not
necessarily have very much context
All code in the "harness" directory adds to the total amount of
project-specific information which contributors are expected to to
learn. In light of the above deficiencies, the burden of this particular
harness file is unjustified.
Remove the harness file and its associated tests. Update the tests which
depend on it to express their expectations using alternate methods, and
strengthen the tests to assert element order wherever appropriate.
[1] https://github.com/tc39/test262/pull/3289
This reverts commit b690cb67be, reversing
changes made to 50dd431dff. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
* Add tests for Object.hasOwn
* Update test/built-ins/Object/hasOwn/length.js
Co-authored-by: Jordan Harband <ljharb@gmail.com>
* Update test/built-ins/Object/hasOwn/name.js
Co-authored-by: Jordan Harband <ljharb@gmail.com>
* Fixup comments for Object.hasOwn
* Add Object.hasOwn descriptor test
* use assert.sameValue with true instead of assert()
* remove extra semicolons
* Remove old $ERROR style tests from hasown
* Fix thrown error type in hasown tests
* Fix incorrect test cases
Co-authored-by: Jordan Harband <ljharb@gmail.com>
A quite popular solution for encrypting files on Linux,
[eCryptfs](https://wiki.archlinux.org/index.php/ECryptfs), can't handle
filenames longer than 143 characters when filename encryption is enabled. It
just so happens that the name of this file was 144 characters long, which makes
pulling the repository to an encrypted folder fail.