Test262 - chapter 15

One single commit to resolve test case failures when running test262-chapter15 tests (only covered non-strict tests!). If you need smaller commits to ease reviewing, let me know!

-- André


ECMAScript5 has changed "15.3.4.4  Function.prototype.call" to longer coerce the `thisObject` by means of ToObject.
That requires a few API changes in Rhino, notably for Callable#call() and IdFunctionCall#execIdCall(). As both
methods are fundamental aspects of any host object in Rhino, the API change triggered changes all over the place.
In the rest of this commit message, file changes are not separately listed below if the changes are only updates
for either call() or execIdCall().

Callable:
- changed `thisObject` type from "Scriptable" to "Object" to conform to ES5
IdFunctionCall:
- changed `thisObject` type from "Scriptable" to "Object" to conform to ES5

xmlbeans/XMLList:
- add cast to XMLObject [short-cut instead of calling ScriptRuntime.toObject()]

Arguments:
- add initial default data-descriptor with {enumerable: true, writable: true, configurable: true} per 10.6 Arguments Object, step 11.b
- required at this point otherwise ScriptableObject#defineOwnProperty() sets the attributes to {enumerable: false, writable: false, configurable: false}
- handle case when only 'writable' is set
- replace isFalse() call with additional check whether 'writable' is actually present in descriptor
- also see [[DefineOwnProperty]] for Arguments step 5.b.i and 5.b.ii

BaseFunction:
- arity of toString() is 1
- realFunction() should default to use `thisObject` as function if valueOf() returns non-function object [valueOf() redefining the function seems to a rhino-specific implementation choice?]
- left backward compatible call() method definition to help users move to new call() interface

IdScriptableObject:
- left backward compatible execIdCall() method definition to help users move to new execIdCall() interface

InterprectedFunction:
- user functions still coerce 'null' and 'undefined' to the global object

Codegen:
- update generated code to match InterprectedFunction

NativeArray:
- [[Put]] cannot add new entries if [[Extensible]] is false, cf. 8.12.4 [[CanPut]]
- added 15.4.5.1 [[DefineOwnProperty]] for the 'length' property on Array
- added 15.4.5.1 [[DefineOwnProperty]] for the index properties on Array
- intercept 'length' and index properties and redirect to the methods listed above
- 'length' must be intercepted for both defineOwnProperty() methods, see defineOwnProperty() in super-class
- copied more or less from setLength(), but includes additional checks and always deletes index properties in descending order as specified in 15.4.5.1 [[DefineOwnProperty]]
- helper method just like setElem(), but uses [[DefineOwnProperty]] instead of [[Put]]
- follow spec for 15.4.4.11  Array.prototype.sort more closely in respect to undefined and not-defined properties
- explicitely call deleteElem() because `thisObject` may not be an Array instance
- always call setLengthProperty() to ensure update to 'length' property b/c it may be implicitely updated due to call to ToUint32 in step 3 of 15.4.4.13  Array.prototype.unshift
- add missing calls to [[Delete]], see step 12.d of 15.4.4.12  Array.prototype.splice
- 15.4.4.4  Array.prototype.concat uses [[DefineOwnProperty]] instead of [[Put]]
- handle case when first argument is `undefined`
- 15.4.4.10  Array.prototype.slice uses [[DefineOwnProperty]] instead of [[Put]]
- removed method, indexOf and lastIndexOf now use seperate methods since the amount of shared lines was negliglible to justify the added non-uniformness compared to the other js_* methods
- 15.4.4.14  Array.prototype.indexOf uses [[Get]], therefore add search for prototype values in the dense-array case
- 15.4.4.15  Array.prototype.lastIndexOf uses [[Get]], therefore add search for prototype values in the dense-array case
- use caution to follow algorithm steps more closely
- 'filter' and 'map' use [[DefineOwnProperty]] instead of [[Put]]
- use caution to follow algorithm steps more closely

NativeDate:
- length of 'constructor' and 'UTC' is 7
- handle case when Date.prototype.toISOString is redefined for Date objects
- Date.prototype.toJSON uses [[GET]] to obtain the "toISOString" property
- don't use Java's DateFormat to parse/format dates from/into ISO-8601 Extended Format strings since DateFormat doesn't follow the syntax from 15.9.1.15  Date Time String Format
- add DaysInMonth method with same contract as DaysInMonth from jsdate.cpp
- add parseISOString method with same contract as in jsdate.cpp, but use a simple state machine since Java doesn't support macros
- parseISOString supports the following two deviations from the spec:
  1) time-only format, e.g. "08:00:00Z"
  2) timezone descriptor without ':' as separator, e.g. "08:00:00+0100" instead of "08:00:00+01:00"
- parseISOString also supports the same input validation as in jsdata.cpp, the spec isn't really clear what to do with invalid input data
- add js_toISOString method to format date values in ISO-8601 Extended Format with expanded year representation if necessary

NativeError:
- properly set default attributes for "name" and "message"
- handle `undefined` value for message in constructor
- follow spec for 15.11.4.4  Error.prototype.toString more closely

NativeGlobal:
- remove IE-support shim for "ConversionError"
- no longer replace 0xFFFE and 0xFFFF with 0xFFFD when decoding URI's

NativeNumber:
- stick with the spec and don't allow non-standard precisions

NativeObject:
- Object.prototype.toLocaleString no longer alias for toString instead follow spec and retrieve current "toString" with [[Get]]
- Object.prototype.valueOf calls ToObject on `thisObject` per spec
- handle `undefined` arguments for Object.prototype.hasOwnProperty and Object.prototype.propertyIsEnumerable
- Object.prototype.isPrototypeOf calls ToObject after argument validation per spec algorithm

NativeString:
- arity of String.prototype.replace is 2
- call CheckObjectCoercible on `thisObject` if required by spec for String.prototype methods
- add more overriden methods to be compliant to 15.5.5.2 [[GetOwnProperty]]
- handle `undefined` arguments in 15.5.4.13  String.prototype.slice

ScriptRuntime:
- add additional defaultObjectToString() method to support 15.2.4.2  Object.prototype.toString
- #numberToString(): first check radix, then process other special values like Infinity etc.
- add #checkObjectCoercible() per 9.10 CheckObjectCoercible
-- don't map `null` or `undefined` to the global object if specified as `thisObject`, cf. 15.3.4.4  Function.prototype.call
-- don't call ToObject for the `thisObject`, cf. 15.3.4.4  Function.prototype.call
- use [[DefineOwnProperty]] rather than [[Put]] in #newArrayLiteral() when creating new Array objects

ScriptableObject:
- add helper methods for defineProperty() which work on integer indices instead of strings
- default getter resp. setter to `undefined` when creating a new accessor property
- 'enumerable' must be present before attempting to reject property change in #checkPropertyChange()

SpecialRef:
- handle the case when an object actually has an own property named "__proto__"

NativeRegExp:
- RegExp is no longer callable, also see https://bugzilla.mozilla.org/show_bug.cgi?id=582717
- change 'lastIndex' property from double to Object to allow lazy evaluation of the property
- handle `undefined` argument when compiling a new RegExp
- make RegExp.prototype.exec work with `undefined` argument
- add lazy evaluation of 'lastIndex' in RegExp.prototype.exec
- additional check to report an error if a RegExp flag appears more than once
- don't allow unqualified '{', cf. `/a{1}{1}/`
- arity of RegExp.prototype.compile is 2

NativeRegExpCtor:
- arity of RegExp constructor is 2

RegExpImpl:
- String.prototype.replace erroneously created a RegExp if the first argument was not already an instanceof RegExp
- move NativeRegExp creation out of matchOrReplace into a new method
- handle `undefined` arguments for String.prototype.{match, search, replace}
- follow String.prototype.split algorithm steps more closely

error.tostring.doctest:
- update expected values, double-checked with SM shell