[JSC] Test262 15.5.4.9_3 test is failing
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Jun 2013 08:08:52 +0000 (08:08 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Jun 2013 08:08:52 +0000 (08:08 +0000)
commit3c1f01f621d3e777e6e75fc314bba2daf67a92e3
tree50adaa12d14684d7096a43019685d98c95c4f613
parent2e5b6c79931de48184f53472fddb3af762e989ad
[JSC] Test262 15.5.4.9_3 test is failing
https://bugs.webkit.org/show_bug.cgi?id=116789

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Bring the String.prototype.localeCompare behavior in line wit ES5 15.9.4.9.
If method is not given enough arguments, the minimal amount of arguments must be assumed, with their value being undefined.
The first argument to localeCompare, in its string form, is used as the 'that' string that's used in the comparison.
Therefor, when calling str.localeCompare() or str.localeCompare(undefined), the first argument is `undefined` and the
string "undefined" is used as the string to which value of str is compared.

* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncLocaleCompare): Remove the early return in case of no given arguments to achieve the desired behavior.

LayoutTests:

Add the 15.5.4.9_3 test from the test262 test suite to cover proper behavior of String.prototype.localeCompare
when no arguments are passed to it. The test tests that str.localeCompare() and str.localeCompare(undefined) work
the same way, i.e. using the string 'undefined' as the string with which str is compared (meaning that the first argument
defaults to 'undefined' when not given).

The test and the rationale behind it originates from bug #1245 in ECMAScript Bugzilla.
https://bugs.ecmascript.org/show_bug.cgi?id=1245

* fast/js/kde/StringObject-expected.txt: Update the baseline.
* fast/js/kde/script-tests/StringObject.js: Update the expected return of the localeCompare test case with no arguments. -1 is
expected as the missing argument defaults to 'undefined' and is then compared to the string on which localeCompare is called.
* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.9_String.prototype.localeCompare/S15.5.4.9_3-expected.txt: Added.
* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.9_String.prototype.localeCompare/S15.5.4.9_3.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151159 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/js/kde/StringObject-expected.txt
LayoutTests/fast/js/kde/script-tests/StringObject.js
LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.9_String.prototype.localeCompare/S15.5.4.9_3-expected.txt [new file with mode: 0644]
LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.9_String.prototype.localeCompare/S15.5.4.9_3.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/StringPrototype.cpp