Skip to content
  • barraclough@apple.com's avatar
    Bug 56077 - ES5 conformance issues with RegExp.prototype · fc9d6415
    barraclough@apple.com authored
    Reviewed by Oliver Hunt.
    
    There are three issues causing test failures in sputnik.
    
    (1) lastIndex should be converted at the point it is used, not the point it is set (this is visible if valueOf is overridden).
    (2) The 'length' property of the test/exec functions should be 1.
    (3) If no input is specified, the input to test()/exec() is "undefined" (i.e. ToString(undefined)) - not RegExp.input.
    
    Source/JavaScriptCore: 
    
    * runtime/RegExpObject.cpp:
    (JSC::RegExpObject::markChildren):
        - Added to mark lastIndex
    (JSC::regExpObjectLastIndex):
    (JSC::setRegExpObjectLastIndex):
        - lastIndex is now stored as a JSValue.
    (JSC::RegExpObject::match):
        - Use accessor methods to get/set lastIndex, add fast case for isUInt32 (don't convert to double).
    * runtime/RegExpObject.h:
    (JSC::RegExpObject::setLastIndex):
    (JSC::RegExpObject::setLastIndex):
        - Set lastIndex, either from a size_t or a JSValue.
    (JSC::RegExpObject::getLastIndex):
        - Get lastIndex.
    (JSC::RegExpObject::RegExpObjectData::RegExpObjectData):
        - Initialize as a JSValue.
    * runtime/RegExpPrototype.cpp:
    (JSC::RegExpPrototype::RegExpPrototype):
        - Add test/exec properties with length 1.
    * runtime/StringPrototype.cpp:
    (JSC::stringProtoFuncMatch):
    (JSC::stringProtoFuncSearch):
        - Do not read RegExp.input if none is provided.
    * tests/mozilla/js1_2/regexp/RegExp_input.js:
    * tests/mozilla/js1_2/regexp/RegExp_input_as_array.js:
        - Update these tests (they relied on non-ES5 behaviour).
    
    LayoutTests: 
    
    * fast/js/kde/function_length-expected.txt:
    * fast/js/kde/script-tests/function_length.js:
        - 'length' of RexExp.test/RexExp.exec is 1
    * fast/js/regexp-caching-expected.txt:
    * fast/js/regexp-test-null-string-expected.txt:
    * fast/js/regexp-test-null-string.html:
        - test() is equivalent to test("undefined")
    * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.2_RegExp.prototype.exec/S15.10.6.2_A11-expected.txt:
    * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.2_RegExp.prototype.exec/S15.10.6.2_A1_T16-expected.txt:
    * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.2_RegExp.prototype.exec/S15.10.6.2_A4_T11-expected.txt:
    * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.3_RegExp.prototype.test/S15.10.6.3_A11-expected.txt:
    * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.3_RegExp.prototype.test/S15.10.6.3_A1_T16-expected.txt:
        - These tests now pass!
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@80743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    fc9d6415