Changeset 203393 in webkit


Ignore:
Timestamp:
Jul 18, 2016, 7:45:35 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Make builtin TypeErrors consistent
https://bugs.webkit.org/show_bug.cgi?id=159899

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-07-18
Reviewed by Keith Miller.

Source/JavaScriptCore:

Converge on the single TypeError for non-coercible this objects in builtins.
Also update some other style to be more consistent with-in builtins.

  • builtins/ArrayIteratorPrototype.js:

(next):

  • builtins/ArrayPrototype.js:

(values):
(keys):
(entries):
(reduce):
(reduceRight):
(every):
(forEach):
(filter):
(map):
(some):
(fill):
(find):
(findIndex):
(includes):
(sort):
(concatSlowPath):
(copyWithin):

  • builtins/StringPrototype.js:

(match):
(repeat):
(padStart):
(padEnd):
(intrinsic.StringPrototypeReplaceIntrinsic.replace):
(localeCompare):
(search):
(split):

  • tests/es6/String.prototype_methods_String.prototype.padEnd.js:
  • tests/es6/String.prototype_methods_String.prototype.padStart.js:
  • tests/stress/array-iterators-next-error-messages.js:

(catch):

  • tests/stress/array-iterators-next-with-call.js:
  • tests/stress/regexp-match.js:

(shouldThrow):

  • tests/stress/regexp-search.js:

(shouldThrow):

LayoutTests:

  • js/array-find-expected.txt:
  • js/array-findIndex-expected.txt:
  • js/array-includes-expected.txt:
  • js/dom/array-prototype-properties-expected.txt:
  • js/dom/script-tests/string-prototype-properties.js:
  • js/dom/string-prototype-properties-expected.txt:
  • js/script-tests/array-find.js:
  • js/script-tests/array-findIndex.js:
  • js/script-tests/string-localeCompare.js:
  • js/string-localeCompare-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T3-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt:
Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203391 r203393  
     12016-07-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Make builtin TypeErrors consistent
     4        https://bugs.webkit.org/show_bug.cgi?id=159899
     5
     6        Reviewed by Keith Miller.
     7
     8        * js/array-find-expected.txt:
     9        * js/array-findIndex-expected.txt:
     10        * js/array-includes-expected.txt:
     11        * js/dom/array-prototype-properties-expected.txt:
     12        * js/dom/script-tests/string-prototype-properties.js:
     13        * js/dom/string-prototype-properties-expected.txt:
     14        * js/script-tests/array-find.js:
     15        * js/script-tests/array-findIndex.js:
     16        * js/script-tests/string-localeCompare.js:
     17        * js/string-localeCompare-expected.txt:
     18        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt:
     19        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T3-expected.txt:
     20        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt:
     21        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt:
     22
    1232016-07-18  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/LayoutTests/js/array-find-expected.txt

    r184848 r203393  
    4343PASS [0,1,2,3,4,5,6,7,8,9].find(findItemRemovedDuringSearch) is undefined
    4444Exceptions
    45 PASS Array.prototype.find.call(undefined, function() {}) threw exception TypeError: Array.prototype.find requires that |this| not be undefined.
    46 PASS Array.prototype.find.call(null, function() {}) threw exception TypeError: Array.prototype.find requires that |this| not be null.
     45PASS Array.prototype.find.call(undefined, function() {}) threw exception TypeError: Array.prototype.find requires that |this| not be null or undefined.
     46PASS Array.prototype.find.call(null, function() {}) threw exception TypeError: Array.prototype.find requires that |this| not be null or undefined.
    4747PASS [].find(1) threw exception TypeError: Array.prototype.find callback must be a function.
    4848PASS [].find('hello') threw exception TypeError: Array.prototype.find callback must be a function.
  • trunk/LayoutTests/js/array-findIndex-expected.txt

    r184848 r203393  
    4444PASS [0,1,2,3,4,5,6,7,8,9].findIndex(findItemRemovedDuringSearch) is -1
    4545Exceptions
    46 PASS Array.prototype.findIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be undefined.
    47 PASS Array.prototype.findIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null.
     46PASS Array.prototype.findIndex.call(undefined, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null or undefined.
     47PASS Array.prototype.findIndex.call(null, function() {}) threw exception TypeError: Array.prototype.findIndex requires that |this| not be null or undefined.
    4848PASS [].findIndex(1) threw exception TypeError: Array.prototype.findIndex callback must be a function.
    4949PASS [].findIndex('hello') threw exception TypeError: Array.prototype.findIndex callback must be a function.
  • trunk/LayoutTests/js/array-includes-expected.txt

    r202926 r203393  
    2929PASS a.includes('hashbrown') is false
    3030PASS a.includes('toast') is false
    31 PASS Array.prototype.includes.call(undefined, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be undefined.
    32 PASS Array.prototype.includes.call(null, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be null.
     31PASS Array.prototype.includes.call(undefined, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be null or undefined.
     32PASS Array.prototype.includes.call(null, 1) threw exception TypeError: Array.prototype.includes requires that |this| not be null or undefined.
    3333Array-like object with invalid lengths
    3434PASS var obj = { 0: 1, 1: 1, 2: 1, length: 0 }; Array.prototype.includes.call(obj, 1) is false
  • trunk/LayoutTests/js/dom/array-prototype-properties-expected.txt

    r202125 r203393  
    66PASS Array.prototype.toString.call(undefined) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.toString.call(undefined)').
    77PASS Array.prototype.toLocaleString.call(undefined) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.toLocaleString.call(undefined)').
    8 PASS Array.prototype.concat.call(undefined, []) threw exception TypeError: Array.prototype.concat requires that |this| not be undefined.
     8PASS Array.prototype.concat.call(undefined, []) threw exception TypeError: Array.prototype.concat requires that |this| not be null or undefined.
    99PASS Array.prototype.join.call(undefined, []) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.join.call(undefined, [])').
    1010PASS Array.prototype.pop.call(undefined) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.pop.call(undefined)').
     
    1313PASS Array.prototype.shift.call(undefined) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.shift.call(undefined)').
    1414PASS Array.prototype.slice.call(undefined, 0, 1) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.slice.call(undefined, 0, 1)').
    15 PASS Array.prototype.sort.call(undefined) threw exception TypeError: Array.prototype.sort requires that |this| not be undefined.
     15PASS Array.prototype.sort.call(undefined) threw exception TypeError: Array.prototype.sort requires that |this| not be null or undefined.
    1616PASS Array.prototype.splice.call(undefined, 0, 1) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.splice.call(undefined, 0, 1)').
    1717PASS Array.prototype.unshift.call(undefined, {}) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.unshift.call(undefined, {})').
    18 PASS Array.prototype.every.call(undefined, toString) threw exception TypeError: Array.prototype.every requires that |this| not be undefined.
    19 PASS Array.prototype.forEach.call(undefined, toString) threw exception TypeError: Array.prototype.forEach requires that |this| not be undefined.
    20 PASS Array.prototype.some.call(undefined, toString) threw exception TypeError: Array.prototype.some requires that |this| not be undefined.
     18PASS Array.prototype.every.call(undefined, toString) threw exception TypeError: Array.prototype.every requires that |this| not be null or undefined.
     19PASS Array.prototype.forEach.call(undefined, toString) threw exception TypeError: Array.prototype.forEach requires that |this| not be null or undefined.
     20PASS Array.prototype.some.call(undefined, toString) threw exception TypeError: Array.prototype.some requires that |this| not be null or undefined.
    2121PASS Array.prototype.indexOf.call(undefined, 0) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.indexOf.call(undefined, 0)').
    2222PASS Array.prototype.lastIndexOf.call(undefined, 0) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.lastIndexOf.call(undefined, 0)').
    23 PASS Array.prototype.filter.call(undefined, toString) threw exception TypeError: Array.prototype.filter requires that |this| not be undefined.
    24 PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: Array.prototype.reduce requires that |this| not be undefined.
    25 PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: Array.prototype.reduceRight requires that |this| not be undefined.
    26 PASS Array.prototype.map.call(undefined, toString) threw exception TypeError: Array.prototype.map requires that |this| not be undefined.
     23PASS Array.prototype.filter.call(undefined, toString) threw exception TypeError: Array.prototype.filter requires that |this| not be null or undefined.
     24PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: Array.prototype.reduce requires that |this| not be null or undefined.
     25PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: Array.prototype.reduceRight requires that |this| not be null or undefined.
     26PASS Array.prototype.map.call(undefined, toString) threw exception TypeError: Array.prototype.map requires that |this| not be null or undefined.
    2727PASS [{toLocaleString:function(){throw 1}},{toLocaleString:function(){throw 2}}].toLocaleString() threw exception 1.
    2828PASS successfullyParsed is true
  • trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js

    r199967 r203393  
    2121shouldThrow("String.prototype.toLowerCase.call(undefined)");
    2222shouldThrow("String.prototype.toUpperCase.call(undefined)");
    23 shouldThrow("String.prototype.localeCompare.call(undefined, '1224')", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'");
     23shouldThrow("String.prototype.localeCompare.call(undefined, '1224')", "'TypeError: String.prototype.localeCompare requires that |this| not be null or undefined'");
    2424shouldThrow("String.prototype.toLocaleLowerCase.call(undefined)");
    2525shouldThrow("String.prototype.toLocaleUpperCase.call(undefined)");
  • trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt

    r200117 r203393  
    1111PASS String.prototype.indexOf.call(undefined, '2') threw exception TypeError: Type error.
    1212PASS String.prototype.lastIndexOf.call(undefined, '2') threw exception TypeError: Type error.
    13 PASS String.prototype.match.call(undefined, /2+/) threw exception TypeError: String.prototype.match requires that |this| not be undefined.
    14 PASS String.prototype.replace.call(undefined, /2+/, '-') threw exception TypeError: String.prototype.replace requires that |this| not be undefined.
    15 PASS String.prototype.search.call(undefined, '4') threw exception TypeError: String.prototype.search requires that |this| not be undefined.
     13PASS String.prototype.match.call(undefined, /2+/) threw exception TypeError: String.prototype.match requires that |this| not be null or undefined.
     14PASS String.prototype.replace.call(undefined, /2+/, '-') threw exception TypeError: String.prototype.replace requires that |this| not be null or undefined.
     15PASS String.prototype.search.call(undefined, '4') threw exception TypeError: String.prototype.search requires that |this| not be null or undefined.
    1616PASS String.prototype.slice.call(undefined, 1, 3) threw exception TypeError: Type error.
    17 PASS String.prototype.split.call(undefined, '2') threw exception TypeError: String.prototype.split requires that |this| not be undefined.
     17PASS String.prototype.split.call(undefined, '2') threw exception TypeError: String.prototype.split requires that |this| not be null or undefined.
    1818PASS String.prototype.slice.call(undefined, 1, 3) threw exception TypeError: Type error.
    1919PASS String.prototype.substr.call(undefined, 1, 3) threw exception TypeError: Type error.
     
    2121PASS String.prototype.toLowerCase.call(undefined) threw exception TypeError: Type error.
    2222PASS String.prototype.toUpperCase.call(undefined) threw exception TypeError: Type error.
    23 PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
     23PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: String.prototype.localeCompare requires that |this| not be null or undefined.
    2424PASS String.prototype.toLocaleLowerCase.call(undefined) threw exception TypeError: Type error.
    2525PASS String.prototype.toLocaleUpperCase.call(undefined) threw exception TypeError: Type error.
  • trunk/LayoutTests/js/script-tests/array-find.js

    r184848 r203393  
    102102
    103103debug("Exceptions");
    104 shouldThrow("Array.prototype.find.call(undefined, function() {})", "'TypeError: Array.prototype.find requires that |this| not be undefined'");
    105 shouldThrow("Array.prototype.find.call(null, function() {})", "'TypeError: Array.prototype.find requires that |this| not be null'");
     104shouldThrow("Array.prototype.find.call(undefined, function() {})", "'TypeError: Array.prototype.find requires that |this| not be null or undefined'");
     105shouldThrow("Array.prototype.find.call(null, function() {})", "'TypeError: Array.prototype.find requires that |this| not be null or undefined'");
    106106shouldThrow("[].find(1)", "'TypeError: Array.prototype.find callback must be a function'");
    107107shouldThrow("[].find('hello')", "'TypeError: Array.prototype.find callback must be a function'");
  • trunk/LayoutTests/js/script-tests/array-findIndex.js

    r184848 r203393  
    104104
    105105debug("Exceptions");
    106 shouldThrow("Array.prototype.findIndex.call(undefined, function() {})", "'TypeError: Array.prototype.findIndex requires that |this| not be undefined'");
    107 shouldThrow("Array.prototype.findIndex.call(null, function() {})", "'TypeError: Array.prototype.findIndex requires that |this| not be null'");
     106shouldThrow("Array.prototype.findIndex.call(undefined, function() {})", "'TypeError: Array.prototype.findIndex requires that |this| not be null or undefined'");
     107shouldThrow("Array.prototype.findIndex.call(null, function() {})", "'TypeError: Array.prototype.findIndex requires that |this| not be null or undefined'");
    108108shouldThrow("[].findIndex(1)", "'TypeError: Array.prototype.findIndex callback must be a function'");
    109109shouldThrow("[].findIndex('hello')", "'TypeError: Array.prototype.findIndex callback must be a function'");
  • trunk/LayoutTests/js/script-tests/string-localeCompare.js

    r200537 r203393  
    88
    99// Test RequireObjectCoercible.
    10 shouldThrow("String.prototype.localeCompare.call()", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'");
    11 shouldThrow("String.prototype.localeCompare.call(undefined)", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'");
    12 shouldThrow("String.prototype.localeCompare.call(null)", "'TypeError: String.prototype.localeCompare requires that |this| not be null'");
     10shouldThrow("String.prototype.localeCompare.call()", "'TypeError: String.prototype.localeCompare requires that |this| not be null or undefined'");
     11shouldThrow("String.prototype.localeCompare.call(undefined)", "'TypeError: String.prototype.localeCompare requires that |this| not be null or undefined'");
     12shouldThrow("String.prototype.localeCompare.call(null)", "'TypeError: String.prototype.localeCompare requires that |this| not be null or undefined'");
    1313shouldNotThrow("String.prototype.localeCompare.call({}, '')");
    1414shouldNotThrow("String.prototype.localeCompare.call([], '')");
  • trunk/LayoutTests/js/string-localeCompare-expected.txt

    r199967 r203393  
    88PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').configurable is true
    99PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').writable is true
    10 PASS String.prototype.localeCompare.call() threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
    11 PASS String.prototype.localeCompare.call(undefined) threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
    12 PASS String.prototype.localeCompare.call(null) threw exception TypeError: String.prototype.localeCompare requires that |this| not be null.
     10PASS String.prototype.localeCompare.call() threw exception TypeError: String.prototype.localeCompare requires that |this| not be null or undefined.
     11PASS String.prototype.localeCompare.call(undefined) threw exception TypeError: String.prototype.localeCompare requires that |this| not be null or undefined.
     12PASS String.prototype.localeCompare.call(null) threw exception TypeError: String.prototype.localeCompare requires that |this| not be null or undefined.
    1313PASS String.prototype.localeCompare.call({}, '') did not throw exception.
    1414PASS String.prototype.localeCompare.call([], '') did not throw exception.
  • trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt

    r198554 r203393  
    11S15.5.4.10_A1_T3
    22
    3 FAIL TypeError: String.prototype.match requires that |this| not be undefined
     3FAIL TypeError: String.prototype.match requires that |this| not be null or undefined
    44
    55TEST COMPLETE
  • trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T3-expected.txt

    r200117 r203393  
    11S15.5.4.11_A1_T3
    22
    3 FAIL TypeError: String.prototype.replace requires that |this| not be undefined
     3FAIL TypeError: String.prototype.replace requires that |this| not be null or undefined
    44
    55TEST COMPLETE
  • trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt

    r196498 r203393  
    11S15.5.4.12_A1_T3
    22
    3 FAIL TypeError: String.prototype.search requires that |this| not be undefined
     3FAIL TypeError: String.prototype.search requires that |this| not be null or undefined
    44
    55TEST COMPLETE
  • trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt

    r199731 r203393  
    11S15.5.4.14_A1_T3
    22
    3 FAIL TypeError: String.prototype.split requires that |this| not be undefined
     3FAIL TypeError: String.prototype.split requires that |this| not be null or undefined
    44
    55TEST COMPLETE
  • trunk/Source/JavaScriptCore/ChangeLog

    r203390 r203393  
     12016-07-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Make builtin TypeErrors consistent
     4        https://bugs.webkit.org/show_bug.cgi?id=159899
     5
     6        Reviewed by Keith Miller.
     7
     8        Converge on the single TypeError for non-coercible this objects in builtins.
     9        Also update some other style to be more consistent with-in builtins.
     10
     11        * builtins/ArrayIteratorPrototype.js:
     12        (next):
     13        * builtins/ArrayPrototype.js:
     14        (values):
     15        (keys):
     16        (entries):
     17        (reduce):
     18        (reduceRight):
     19        (every):
     20        (forEach):
     21        (filter):
     22        (map):
     23        (some):
     24        (fill):
     25        (find):
     26        (findIndex):
     27        (includes):
     28        (sort):
     29        (concatSlowPath):
     30        (copyWithin):
     31        * builtins/StringPrototype.js:
     32        (match):
     33        (repeat):
     34        (padStart):
     35        (padEnd):
     36        (intrinsic.StringPrototypeReplaceIntrinsic.replace):
     37        (localeCompare):
     38        (search):
     39        (split):
     40        * tests/es6/String.prototype_methods_String.prototype.padEnd.js:
     41        * tests/es6/String.prototype_methods_String.prototype.padStart.js:
     42        * tests/stress/array-iterators-next-error-messages.js:
     43        (catch):
     44        * tests/stress/array-iterators-next-with-call.js:
     45        * tests/stress/regexp-match.js:
     46        (shouldThrow):
     47        * tests/stress/regexp-search.js:
     48        (shouldThrow):
     49
    1502016-07-17  Filip Pizlo  <fpizlo@apple.com>
    251
  • trunk/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js

    r202280 r203393  
    2929    "use strict";
    3030
    31     if (this == null) {
    32         if (this === null)
    33             throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null");
    34         throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be undefined");
    35     }
     31    if (this == null)
     32        throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
    3633
    3734    let next = this.@arrayIteratorNext;
  • trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js

    r202926 r203393  
    3939{
    4040    "use strict";
    41     if (this == null) {
    42         if (this === null)
    43             throw new @TypeError("Array.prototype.values requires that |this| not be null");
    44         throw new @TypeError("Array.prototype.values requires that |this| not be undefined");
    45     }
     41
     42    if (this == null)
     43        throw new @TypeError("Array.prototype.values requires that |this| not be null or undefined");
     44
    4645    return new @createArrayIterator(@Object(this), "value", @arrayIteratorValueNext);
    4746}
     
    5049{
    5150    "use strict";
    52     if (this == null) {
    53         if (this === null)
    54             throw new @TypeError("Array.prototype.keys requires that |this| not be null");
    55         throw new @TypeError("Array.prototype.keys requires that |this| not be undefined");
    56     }
     51
     52    if (this == null)
     53        throw new @TypeError("Array.prototype.keys requires that |this| not be null or undefined");
    5754
    5855    return new @createArrayIterator(@Object(this), "key", @arrayIteratorKeyNext);
     
    6259{
    6360    "use strict";
    64     if (this == null) {
    65         if (this === null)
    66             throw new @TypeError("Array.prototype.entries requires that |this| not be null");
    67         throw new @TypeError("Array.prototype.entries requires that |this| not be undefined");
    68     }
     61
     62    if (this == null)
     63        throw new @TypeError("Array.prototype.entries requires that |this| not be null or undefined");
    6964
    7065    return new @createArrayIterator(@Object(this), "key+value", @arrayIteratorKeyValueNext);
     
    7570    "use strict";
    7671
    77     if (this === null)
    78         throw new @TypeError("Array.prototype.reduce requires that |this| not be null");
    79 
    80     if (this === @undefined)
    81         throw new @TypeError("Array.prototype.reduce requires that |this| not be undefined");
     72    if (this == null)
     73        throw new @TypeError("Array.prototype.reduce requires that |this| not be null or undefined");
    8274
    8375    var array = @Object(this);
     
    113105    "use strict";
    114106
    115     if (this === null)
    116         throw new @TypeError("Array.prototype.reduceRight requires that |this| not be null");
    117 
    118     if (this === @undefined)
    119         throw new @TypeError("Array.prototype.reduceRight requires that |this| not be undefined");
     107    if (this == null)
     108        throw new @TypeError("Array.prototype.reduceRight requires that |this| not be null or undefined");
    120109
    121110    var array = @Object(this);
     
    151140    "use strict";
    152141
    153     if (this === null)
    154         throw new @TypeError("Array.prototype.every requires that |this| not be null");
    155    
    156     if (this === @undefined)
    157         throw new @TypeError("Array.prototype.every requires that |this| not be undefined");
     142    if (this == null)
     143        throw new @TypeError("Array.prototype.every requires that |this| not be null or undefined");
    158144   
    159145    var array = @Object(this);
     
    179165    "use strict";
    180166
    181     if (this === null)
    182         throw new @TypeError("Array.prototype.forEach requires that |this| not be null");
    183    
    184     if (this === @undefined)
    185         throw new @TypeError("Array.prototype.forEach requires that |this| not be undefined");
     167    if (this == null)
     168        throw new @TypeError("Array.prototype.forEach requires that |this| not be null or undefined");
    186169   
    187170    var array = @Object(this);
     
    203186    "use strict";
    204187
    205     if (this === null)
    206         throw new @TypeError("Array.prototype.filter requires that |this| not be null");
    207    
    208     if (this === @undefined)
    209         throw new @TypeError("Array.prototype.filter requires that |this| not be undefined");
     188    if (this == null)
     189        throw new @TypeError("Array.prototype.filter requires that |this| not be null or undefined");
    210190   
    211191    var array = @Object(this);
     
    255235    "use strict";
    256236
    257     if (this === null)
    258         throw new @TypeError("Array.prototype.map requires that |this| not be null");
    259    
    260     if (this === @undefined)
    261         throw new @TypeError("Array.prototype.map requires that |this| not be undefined");
     237    if (this == null)
     238        throw new @TypeError("Array.prototype.map requires that |this| not be null or undefined");
    262239   
    263240    var array = @Object(this);
     
    304281    "use strict";
    305282
    306     if (this === null)
    307         throw new @TypeError("Array.prototype.some requires that |this| not be null");
    308    
    309     if (this === @undefined)
    310         throw new @TypeError("Array.prototype.some requires that |this| not be undefined");
     283    if (this == null)
     284        throw new @TypeError("Array.prototype.some requires that |this| not be null or undefined");
    311285   
    312286    var array = @Object(this);
     
    330304    "use strict";
    331305
    332     if (this === null)
    333         throw new @TypeError("Array.prototype.fill requires that |this| not be null");
    334    
    335     if (this === @undefined)
    336         throw new @TypeError("Array.prototype.fill requires that |this| not be undefined");
    337     var O = @Object(this);
    338     var len = @toLength(O.length);
     306    if (this == null)
     307        throw new @TypeError("Array.prototype.fill requires that |this| not be null or undefined");
     308
     309    var array = @Object(this);
     310    var length = @toLength(array.length);
     311
    339312    var relativeStart = 0;
    340313    if (arguments.length > 1 && arguments[1] !== @undefined)
     
    342315    var k = 0;
    343316    if (relativeStart < 0) {
    344         k = len + relativeStart;
     317        k = length + relativeStart;
    345318        if (k < 0)
    346319            k = 0;
    347320    } else {
    348321        k = relativeStart;
    349         if (k > len)
    350             k = len;
    351     }
    352     var relativeEnd = len;
     322        if (k > length)
     323            k = length;
     324    }
     325    var relativeEnd = length;
    353326    if (arguments.length > 2 && arguments[2] !== @undefined)
    354327        relativeEnd = arguments[2] | 0;
    355328    var final = 0;
    356329    if (relativeEnd < 0) {
    357         final = len + relativeEnd;
     330        final = length + relativeEnd;
    358331        if (final < 0)
    359332            final = 0;
    360333    } else {
    361334        final = relativeEnd;
    362         if (final > len)
    363             final = len;
     335        if (final > length)
     336            final = length;
    364337    }
    365338    for (; k < final; k++)
    366         O[k] = value;
    367     return O;
     339        array[k] = value;
     340    return array;
    368341}
    369342
     
    372345    "use strict";
    373346
    374     if (this === null)
    375         throw new @TypeError("Array.prototype.find requires that |this| not be null");
    376    
    377     if (this === @undefined)
    378         throw new @TypeError("Array.prototype.find requires that |this| not be undefined");
     347    if (this == null)
     348        throw new @TypeError("Array.prototype.find requires that |this| not be null or undefined");
    379349   
    380350    var array = @Object(this);
     
    397367    "use strict";
    398368
    399     if (this === null)
    400         throw new @TypeError("Array.prototype.findIndex requires that |this| not be null");
    401    
    402     if (this === @undefined)
    403         throw new @TypeError("Array.prototype.findIndex requires that |this| not be undefined");
     369    if (this == null)
     370        throw new @TypeError("Array.prototype.findIndex requires that |this| not be null or undefined");
    404371   
    405372    var array = @Object(this);
     
    421388    "use strict";
    422389
    423     if (this === null)
    424         throw new @TypeError("Array.prototype.includes requires that |this| not be null");
    425 
    426     if (this === @undefined)
    427         throw new @TypeError("Array.prototype.includes requires that |this| not be undefined");
     390    if (this == null)
     391        throw new @TypeError("Array.prototype.includes requires that |this| not be null or undefined");
    428392
    429393    var array = @Object(this);
     
    674638    }
    675639
    676     if (this === null)
    677         throw new @TypeError("Array.prototype.sort requires that |this| not be null");
    678 
    679     if (this === @undefined)
    680         throw new @TypeError("Array.prototype.sort requires that |this| not be undefined");
     640    if (this == null)
     641        throw new @TypeError("Array.prototype.sort requires that |this| not be null or undefined");
    681642
    682643    if (typeof this == "string")
     
    696657{
    697658    "use strict";
    698     if (this == null) {
    699         if (this === null)
    700             throw new @TypeError("Array.prototype.concat requires that |this| not be null");
    701         throw new @TypeError("Array.prototype.concat requires that |this| not be undefined");
    702     }
     659
     660    if (this == null)
     661        throw new @TypeError("Array.prototype.concat requires that |this| not be null or undefined");
    703662
    704663    var currentElement = @Object(this);
     
    787746    }
    788747
    789     if (this === null || this === @undefined)
     748    if (this == null)
    790749        throw new @TypeError("Array.copyWithin requires that |this| not be null or undefined");
    791     var thisObject = @Object(this);
    792 
    793     var length = @toLength(thisObject.length);
     750
     751    var array = @Object(this);
     752    var length = @toLength(array.length);
    794753
    795754    var relativeTarget = @toInteger(target);
     
    821780
    822781    for (var i = 0; i < count; ++i, from += direction, to += direction) {
    823         if (from in thisObject)
    824             thisObject[to] = thisObject[from];
     782        if (from in array)
     783            array[to] = array[from];
    825784        else
    826             delete thisObject[to];
    827     }
    828 
    829     return thisObject;
    830 }
     785            delete array[to];
     786    }
     787
     788    return array;
     789}
  • trunk/Source/JavaScriptCore/builtins/StringPrototype.js

    r202966 r203393  
    3030    "use strict";
    3131
    32     if (this == null) {
    33         if (this === null)
    34             throw new @TypeError("String.prototype.match requires that |this| not be null");
    35         throw new @TypeError("String.prototype.match requires that |this| not be undefined");
    36     }
     32    if (this == null)
     33        throw new @TypeError("String.prototype.match requires that |this| not be null or undefined");
    3734
    3835    if (regexp != null) {
     
    105102    "use strict";
    106103
    107     if (this == null) {
    108         var message = "String.prototype.repeat requires that |this| not be undefined";
    109         if (this === null)
    110             message = "String.prototype.repeat requires that |this| not be null";
    111         throw new @TypeError(message);
    112     }
     104    if (this == null)
     105        throw new @TypeError("String.prototype.repeat requires that |this| not be null or undefined");
    113106
    114107    var string = @toString(this);
     
    131124    "use strict";
    132125
    133     if (this === null)
    134         throw new @TypeError("String.prototype.padStart requires that |this| not be null");
    135    
    136     if (this === @undefined)
    137         throw new @TypeError("String.prototype.padStart requires that |this| not be undefined");
     126    if (this == null)
     127        throw new @TypeError("String.prototype.padStart requires that |this| not be null or undefined");
    138128
    139129    var string = @toString(this);
     
    171161    "use strict";
    172162
    173     if (this === null)
    174         throw new @TypeError("String.prototype.padEnd requires that |this| not be null");
    175    
    176     if (this === @undefined)
    177         throw new @TypeError("String.prototype.padEnd requires that |this| not be undefined");
     163    if (this == null)
     164        throw new @TypeError("String.prototype.padEnd requires that |this| not be null or undefined");
    178165
    179166    var string = @toString(this);
     
    232219    "use strict";
    233220
    234     if (this == null) {
    235         if (this === null)
    236             throw new @TypeError("String.prototype.replace requires that |this| not be null");
    237         throw new @TypeError("String.prototype.replace requires that |this| not be undefined");
    238     }
     221    if (this == null)
     222        throw new @TypeError("String.prototype.replace requires that |this| not be null or undefined");
    239223
    240224    if (search != null) {
     
    260244
    261245    // 1. Let O be RequireObjectCoercible(this value).
    262     if (this === null)
    263         throw new @TypeError("String.prototype.localeCompare requires that |this| not be null");
    264    
    265     if (this === @undefined)
    266         throw new @TypeError("String.prototype.localeCompare requires that |this| not be undefined");
     246    if (this == null)
     247        throw new @TypeError("String.prototype.localeCompare requires that |this| not be null or undefined");
    267248
    268249    // 2. Let S be ToString(O).
     
    290271    "use strict";
    291272
    292     if (this == null) {
    293         if (this === null)
    294             throw new @TypeError("String.prototype.search requires that |this| not be null");
    295         throw new @TypeError("String.prototype.search requires that |this| not be undefined");
    296     }
     273    if (this == null)
     274        throw new @TypeError("String.prototype.search requires that |this| not be null or undefined");
    297275
    298276    if (regexp != null) {
     
    311289    "use strict";
    312290   
    313     if (this == null) {
    314         if (this === null)
    315             throw new @TypeError("String.prototype.split requires that |this| not be null");
    316         throw new @TypeError("String.prototype.split requires that |this| not be undefined");
    317     }
     291    if (this == null)
     292        throw new @TypeError("String.prototype.split requires that |this| not be null or undefined");
    318293   
    319294    if (separator != null) {
  • trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js

    r202966 r203393  
    4242(function TestRequireObjectCoercible() {
    4343    var padEnd = String.prototype.padEnd;
    44     shouldThrow(() => padEnd.call(null, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be null");
    45     shouldThrow(() => padEnd.call(undefined, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be undefined");
     44    shouldThrow(() => padEnd.call(null, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be null or undefined");
     45    shouldThrow(() => padEnd.call(undefined, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be null or undefined");
    4646    shouldBe("123   ", padEnd.call({
    4747        __proto__: null,
  • trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js

    r202966 r203393  
    4242(function TestRequireObjectCoercible() {
    4343    var padStart = String.prototype.padStart;
    44     shouldThrow(() => padStart.call(null, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be null");
    45     shouldThrow(() => padStart.call(undefined, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be undefined");
     44    shouldThrow(() => padStart.call(null, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be null or undefined");
     45    shouldThrow(() => padStart.call(undefined, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be null or undefined");
    4646    shouldBe("   123", padStart.call({
    4747        __proto__: null,
  • trunk/Source/JavaScriptCore/tests/stress/array-iterators-next-error-messages.js

    r200428 r203393  
    99    next.call(null);
    1010} catch(e) {
    11     assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null");
     11    assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
    1212}
    1313
     
    1515    next.call(undefined);
    1616} catch(e) {
    17     assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be undefined");
     17    assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
    1818}
  • trunk/Source/JavaScriptCore/tests/stress/array-iterators-next-with-call.js

    r200434 r203393  
    8686    var expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance';
    8787    if (primitive === null)
    88         expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null';
     88        expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null or undefined';
    8989    if (primitive === undefined)
    90         expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| not be undefined';
     90        expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null or undefined';
    9191    if (String(didThrow) !== expectedMessage)
    9292        throw "Error: bad error thrown: " + didThrow;
  • trunk/Source/JavaScriptCore/tests/stress/regexp-match.js

    r198554 r203393  
    2626shouldThrow(function () {
    2727    String.prototype.match.call(null, /Cocoa/);
    28 }, "TypeError: String.prototype.match requires that |this| not be null");
     28}, "TypeError: String.prototype.match requires that |this| not be null or undefined");
    2929
    3030shouldThrow(function () {
    3131    String.prototype.match.call(undefined, /Cocoa/);
    32 }, "TypeError: String.prototype.match requires that |this| not be undefined");
     32}, "TypeError: String.prototype.match requires that |this| not be null or undefined");
    3333
    3434shouldThrow(function () {
  • trunk/Source/JavaScriptCore/tests/stress/regexp-search.js

    r199748 r203393  
    2626shouldThrow(function () {
    2727    String.prototype.search.call(null, /Cocoa/);
    28 }, "TypeError: String.prototype.search requires that |this| not be null");
     28}, "TypeError: String.prototype.search requires that |this| not be null or undefined");
    2929
    3030shouldThrow(function () {
    3131    String.prototype.search.call(undefined, /Cocoa/);
    32 }, "TypeError: String.prototype.search requires that |this| not be undefined");
     32}, "TypeError: String.prototype.search requires that |this| not be null or undefined");
    3333
    3434shouldThrow(function () {
Note: See TracChangeset for help on using the changeset viewer.