Commit Graph

197 Commits

Author SHA1 Message Date
Shu-yu Guo 2f0193d4cf Add missing iterator-helpers feature flag 2023-06-15 20:18:14 +02:00
Rick Waldron dfc7ce4c28
Iterator Helpers (#2818)
drop:

property descriptor
name
length
[[Prototype]]
is a function
is not constructible
result instanceof Iterator
limit is given a non-primitive that needs to be converted to a number
  through valueOf
  through toString (array)
limit coercion to number throws
limit converts to NaN
  same as limit not supplied
limit behaves properly
  limit < number of values
  limit = number of values
  limit > number of values
gets the next method from the underlying iterator only once
underlying iterator has throwing next getter
underlying iterator next throws when advancing past dropped items
underlying iterator is advanced after calling drop
underlying iterator is closed after calling drop
underlying iterator is already closed
underlying iterator next returns non-object
underlying iterator next returns object with throwing done/value getters
underlying iterator return is never called when result iterator is closed

every:

property descriptor
name
length
[[Prototype]]
is a function
is callable
is not constructible
result is a Boolean
predicate is non-callable
iterator already exhausted
called on non-object
called on object with "next" method
called on object with non-callable "next" method
predicate returns non-Boolean
predicate returns truthy for all iterated values
  returns true
predicate returns truthy for some iterated values but then falsey for at least one iterated value
  returns false
  iteration stops
  iterator is closed
predicate returns falsey immediately
  returns false
  iteration stops
  iterator is closed
predicate throws
  every throws
  iterator is closed
predicate throws then iterator close also throws
predicate this value is undefined
predicate is passed the yielded value as the first parameter and a counter as second parameter
gets the next method from the iterator only once
iterator has throwing next getter
iterator has throwing return getter
iterator next throws
iterator return throws
iterator next returns non-object
iterator next returns object with throwing done/value getters

Co-authored-by: Michael Ficarra <mficarra@shapesecurity.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-06-15 17:07:41 +02:00
Jordan Harband c5b24c64c3
groupBy: fix throwing iterator tests
Fixes #3852
2023-06-13 19:56:17 -07:00
Jordan Harband 49237f30de Convert Array.prototype.group tests to Object.groupBy tests 2023-05-31 08:32:28 -07:00
Jordan Harband 910a2764d8 Object.prototype.toString: avoid over-DRYness, and add preconditions 2023-03-27 11:21:34 +02:00
Philip Chimento d87a7da6e1 Replace Object.hasOwnProperty.call with Object.prototype.hasOwnProperty.call
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
2022-11-30 16:04:02 -08:00
Marko Lahma 91356f52f9 Add AggregateError as feature to seal-aggregateerror.js 2022-01-11 10:08:18 -05:00
Csaba Osztrogonác bd1acb51a4 tools: enforce restriction on YAML includes key
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.
2022-01-05 17:27:58 -05:00
Mike Pennisi 6d5975defc Remove duplicated constructor tests
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
2021-12-14 13:38:51 -05:00
Mike Pennisi f782971ad2 Remove harness file, arrayContains.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
2021-11-01 12:55:10 -04:00
Rick Waldron 4ce285da7a
Transform compareArray -> assert.compareArray: test/built-ins/Object/**/*.js (#3236) 2021-10-08 16:13:08 -04:00
Mike Pennisi d9ddf80479 Revert "Merge pull request #3219 from tc39/rwaldron/migrate-comparearray"
This reverts commit b690cb67be, reversing
changes made to 50dd431dff. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
2021-10-01 10:18:47 -04:00
rwaldron 4847d9db5a chore: update test/**/*.js to use assert.compareArray wherever applicable 2021-09-24 12:58:15 -04:00
rwaldron 19d081ef1d Transform legacy format to harness assertions: test/built-ins/O*/**/*.js 2021-09-02 11:34:27 -07:00
André Bargull 47be34cef7 Split files which test for the property order of functions
So SpiderMonkey can run the other parts of these tests.
2021-08-05 18:23:52 -04:00
Rick Waldron ecf835778d
chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Object (#3090) 2021-07-28 13:50:06 -07:00
Jamie Kyle bad7c0487e
Add tests for Object.hasOwn (#2995)
* 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>
2021-06-16 17:35:06 -04:00
Alexey Shvayka 950d097516 Add Object.freeze test 2021-02-08 15:41:23 -05:00
Alexey Shvayka a4ca510b55 Add Object.seal test 2021-02-08 15:41:23 -05:00
Alexey Shvayka fd6bbbe581 Add Object.freeze tests 2021-02-08 15:40:48 -05:00
Alexey Shvayka 1fd4fb480c Add Object.seal tests 2021-02-08 15:40:48 -05:00
Alexey Shvayka 83ffa3d911 Add Object.preventExtensions tests 2021-02-08 15:40:48 -05:00
ExE Boss 8f904d8cc8 Set function `length` and `name` in `CreateBuiltinFunction` 2021-01-29 09:45:20 -05:00
Oskari Noppa a840b0d093 Shorten a very long filename
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.
2021-01-19 09:06:30 -05:00
Rick Waldron cef698c374 Rename long test file names 2020-10-29 13:49:25 -04:00
Rick Waldron 1af15d5199 Add missing features flags 2020-10-29 13:20:18 -04:00
devsnek 52cb1d0c98 Add missing feature 2020-10-08 20:13:18 -04:00
Gus Caplan 6aa8338d23 add feature tags 2020-10-08 18:05:00 -04:00
Gus Caplan 881c9e3ba5 move __proto__ tests 2020-10-08 18:05:00 -04:00
Gus Caplan 14788fee59 move define/lookup tests 2020-10-08 18:05:00 -04:00
Rick Waldron d576baf73f Info: adds "sec-evaluatenew" step to info for all "not-a-constructor.js" tests. 2020-10-06 12:01:34 -04:00
Rick Waldron 8aacff591c Standardize built-in constructor testing 2020-10-06 12:01:34 -04:00
Rick Waldron 12ed905003 Clean up some existing constructor checks; eliminate duplicate checks 2020-10-06 12:01:34 -04:00
Rick Waldron c644ede430 Built-in function objects that are not identified as constructors must throw a TypeError exception when new'ed. Fixes gh-1739 2020-10-06 12:01:34 -04:00
Rick Waldron 8a65608dc2 Coverage: Object.seal instances of all built-in constructors, and other built-in values. Fixes gh-2845 2020-10-05 14:38:41 -04:00
Rick Waldron c0b18dfadf Cleanup 2020-10-05 14:38:41 -04:00
Rick Waldron 9d345b6a85 Coverage: Object.seal instances of all built-in constructors. Fixes gh-2845 2020-10-05 14:38:41 -04:00
Rick Waldron d6732b2e28 Object.seal: rename in modern form. 2020-10-05 14:38:41 -04:00
Rick Waldron 32334e52ac Object.seal: fix esids 2020-10-05 14:38:41 -04:00
Rick Waldron dcbc02b7fa Coverage: Object.getOwnPropertySymbols/Names called with non-object values. Fixes gh-2804 2020-09-24 14:53:26 -04:00
Rick Waldron b11c1607c0 Coverage: Object.assign, Assignment to readonly property of target must throw a TypeError exception. Fixes gh-2788 2020-09-17 16:21:26 -04:00
Rick Waldron 1cd7d87501 Object.defineProperty: Property description must be an object. Fixes gh-1754 2020-09-17 09:59:31 -04:00
Rick Waldron db5b9c1dd9 Object.defineProperties: Property description must be an object. Fixes gh-1754 2020-09-17 09:59:31 -04:00
Rick Waldron 896994413c
Missing coverage for Object.defineProperty method. Fixes gh-2660 (#2738) 2020-08-31 12:59:07 -07:00
Meir Blachman f7322cca7a use $ERROR instead of throwing in 15.2.3.7-2-18.js 2020-06-24 12:25:30 -04:00
Alexey Shvayka 0fcc51c9e2 Update copyright for "length" test 2020-06-03 14:03:21 -04:00
Alexey Shvayka 3a4bd7d050 Add symbol primitive test 2020-06-03 14:03:21 -04:00
Alexey Shvayka 38050f0cdd Add string primitive test 2020-06-03 14:03:21 -04:00
Alexey Shvayka f4b30daf12 Rename & improve "length" test 2020-06-03 14:03:21 -04:00
Alexey Shvayka 1fccea4471 Object.prototype.hasOwnProperty: Test coercion order 2020-05-06 11:56:49 -04:00