...for the non-success state. This fixes a crash when parsing dates with
the year -1, as we would assert successful parsing ("year != -1").
Mixing Optional and -1 seems worse and more complicated than just using
Optional for all the values, so I did that instead.
It is defined as follows:
21.4.3.1 Date.now ( )
https://tc39.es/ecma262/#sec-date.now
The now function returns the time value designating the UTC date and
time of the occurrence of the call to now.
"Time value" is defined as:
21.4.1.1 Time Values and Time Range
https://tc39.es/ecma262/#sec-time-values-and-time-range
An ECMAScript time value is a Number, either a finite integral
Number representing an instant in time to millisecond precision or
NaN representing no specific instant.
By flooring the value we match the behavior in the Temporal proposal's
Temporal.ZonedDateTime.prototype.epochMilliseconds getter:
4. Let ms be RoundTowardsZero(ℝ(ns) / 10^6).
With that being defined as:
13.30 RoundTowardsZero ( x )
https://tc39.es/proposal-temporal/#sec-temporal-roundtowardszero
1. Return the mathematical value that is the same sign as x and
whose magnitude is floor(abs(x)).
This is makes the last of the currently 15 Temporal tests in test262
work, which compares Temporal.now.instant() with Date.now() :^)
This allows passing an existing RegExp object (or an object that is
sufficiently like a RegExp object) as the "pattern" argument of the
RegExp constructor.
Unfortunately this fast path leads to problems if Array.prototype is
changed. We probably need to find out some way to optimize these methods
by detecting changes to the prototype or other mechanisms.
This only causes 1 new test262 test to pass. Other tests that rely on
this coercion fail due to receiving an unexpected value for 'this' when
invoking a functional replacement. For example:
String/prototype/replaceAll/replaceValue-call-matching-empty.js
Receives 'undefined' for 'this' in the functional replacement invocation
but is expected to receive the global 'this'.
The String.prototype.replace spec requires evaluating the replacement
value (if it is not a function) before searching the source string.
Fixes 4 test262 tests.
10.4.2 Array Exotic Objects
https://tc39.es/ecma262/#sec-array-exotic-objects
A String property name P is an array index if and only if
ToString(ToUint32(P)) equals P and ToUint32(P) is not the same value
as 𝔽(2^32 - 1).
Per the spec, before invoking the GetSubstitution abstraction, the named
capture groups (if not undefined) should be coerced to an object via the
ToObject abstraction.
The implementation of String.prototype.replaceAll cannot use AK's
implementation of String::find_all when finding the indices of the
search string in the source string. String::find_all will return indices
[0, 1] for String("aaa").find_all("aa") - i.e. it returns overlapping
results. This is not allowed by the JavaScript specification for
replaceAll.
This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.