Changeset 191300 in webkit


Ignore:
Timestamp:
Oct 19, 2015, 11:32:30 AM (10 years ago)
Author:
keith_miller@apple.com
Message:

Add regression tests for TypedArray.prototype functions' error messages.
https://bugs.webkit.org/show_bug.cgi?id=150288

Reviewed by Darin Adler.

Fix a typo in the text passed by TypedArrray.prototype.filter type error message.
Add tests that check the actual error message text for all the TypeArray.prototype
functions that throw.

  • builtins/TypedArray.prototype.js:

(filter):

  • tests/stress/typedarray-every.js:
  • tests/stress/typedarray-filter.js:
  • tests/stress/typedarray-find.js:
  • tests/stress/typedarray-findIndex.js:
  • tests/stress/typedarray-forEach.js:
  • tests/stress/typedarray-map.js:
  • tests/stress/typedarray-reduce.js:
  • tests/stress/typedarray-reduceRight.js:
  • tests/stress/typedarray-some.js:
Location:
trunk/Source/JavaScriptCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r191299 r191300  
     12015-10-17  Keith Miller  <keith_miller@apple.com>
     2
     3        Add regression tests for TypedArray.prototype functions' error messages.
     4        https://bugs.webkit.org/show_bug.cgi?id=150288
     5
     6        Reviewed by Darin Adler.
     7
     8        Fix a typo in the text passed by TypedArrray.prototype.filter type error message.
     9        Add tests that check the actual error message text for all the TypeArray.prototype
     10        functions that throw.
     11
     12        * builtins/TypedArray.prototype.js:
     13        (filter):
     14        * tests/stress/typedarray-every.js:
     15        * tests/stress/typedarray-filter.js:
     16        * tests/stress/typedarray-find.js:
     17        * tests/stress/typedarray-findIndex.js:
     18        * tests/stress/typedarray-forEach.js:
     19        * tests/stress/typedarray-map.js:
     20        * tests/stress/typedarray-reduce.js:
     21        * tests/stress/typedarray-reduceRight.js:
     22        * tests/stress/typedarray-some.js:
     23
    1242015-10-19  Tim Horton  <timothy_horton@apple.com>
    225
  • trunk/Source/JavaScriptCore/builtins/TypedArray.prototype.js

    r191225 r191300  
    250250
    251251    if (typeof callback !== "function")
    252         throw new @TypeError("Array.prototype.filter callback must be a function");
     252        throw new @TypeError("TypedArray.prototype.filter callback must be a function");
    253253
    254254    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-every.js

    r190429 r191300  
    4747
    4848debug("5.0 Wrong Type for Callback Test");
    49 shouldThrow("testPrototypeFunction('every', '(8)', [12, 15, 10, 13, 44], false)");
    50 shouldThrow("testPrototypeFunction('every', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    51 shouldThrow("testPrototypeFunction('every', '(new Object())', [12, 15, 10, 13, 44], false)");
    52 shouldThrow("testPrototypeFunction('every', '(null)', [12, 15, 10, 13, 44], false)");
    53 shouldThrow("testPrototypeFunction('every', '()', [12, 15, 10, 13, 44], false)");
     49shouldThrow("testPrototypeFunction('every', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.every callback must be a function'");
     50shouldThrow("testPrototypeFunction('every', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.every callback must be a function'");
     51shouldThrow("testPrototypeFunction('every', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.every callback must be a function'");
     52shouldThrow("testPrototypeFunction('every', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.every callback must be a function'");
     53shouldThrow("testPrototypeFunction('every', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.every callback must be a function'");
    5454debug("");
    5555
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-filter.js

    r190429 r191300  
    4343
    4444debug("5.0 Wrong Type for Callback Test");
    45 shouldThrow("testPrototypeFunction('filter', '(8)', [12, 15, 10, 13, 44], false)");
    46 shouldThrow("testPrototypeFunction('filter', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    47 shouldThrow("testPrototypeFunction('filter', '(new Object())', [12, 15, 10, 13, 44], false)");
    48 shouldThrow("testPrototypeFunction('filter', '(null)', [12, 15, 10, 13, 44], false)");
    49 shouldThrow("testPrototypeFunction('filter', '()', [12, 15, 10, 13, 44], false)");
     45shouldThrow("testPrototypeFunction('filter', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.filter callback must be a function'");
     46shouldThrow("testPrototypeFunction('filter', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.filter callback must be a function'");
     47shouldThrow("testPrototypeFunction('filter', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.filter callback must be a function'");
     48shouldThrow("testPrototypeFunction('filter', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.filter callback must be a function'");
     49shouldThrow("testPrototypeFunction('filter', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.filter callback must be a function'");
    5050debug("");
    5151finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-find.js

    r190429 r191300  
    4545
    4646debug("5.0 Wrong Type for Callback Test");
    47 shouldThrow("testPrototypeFunction('find', '(8)', [12, 15, 10, 13, 44], false)");
    48 shouldThrow("testPrototypeFunction('find', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    49 shouldThrow("testPrototypeFunction('find', '(new Object())', [12, 15, 10, 13, 44], false)");
    50 shouldThrow("testPrototypeFunction('find', '(null)', [12, 15, 10, 13, 44], false)");
    51 shouldThrow("testPrototypeFunction('find', '()', [12, 15, 10, 13, 44], false)");
     47shouldThrow("testPrototypeFunction('find', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.find callback must be a function'");
     48shouldThrow("testPrototypeFunction('find', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.find callback must be a function'");
     49shouldThrow("testPrototypeFunction('find', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.find callback must be a function'");
     50shouldThrow("testPrototypeFunction('find', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.find callback must be a function'");
     51shouldThrow("testPrototypeFunction('find', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.find callback must be a function'");
    5252debug("");
    5353finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-findIndex.js

    r190429 r191300  
    4545
    4646debug("5.0 Wrong Type for Callback Test");
    47 shouldThrow("testPrototypeFunction('findIndex', '(8)', [12, 15, 10, 13, 44], false)");
    48 shouldThrow("testPrototypeFunction('findIndex', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    49 shouldThrow("testPrototypeFunction('findIndex', '(new Object())', [12, 15, 10, 13, 44], false)");
    50 shouldThrow("testPrototypeFunction('findIndex', '(null)', [12, 15, 10, 13, 44], false)");
    51 shouldThrow("testPrototypeFunction('findIndex', '()', [12, 15, 10, 13, 44], false)");
     47shouldThrow("testPrototypeFunction('findIndex', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.findIndex callback must be a function'");
     48shouldThrow("testPrototypeFunction('findIndex', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.findIndex callback must be a function'");
     49shouldThrow("testPrototypeFunction('findIndex', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.findIndex callback must be a function'");
     50shouldThrow("testPrototypeFunction('findIndex', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.findIndex callback must be a function'");
     51shouldThrow("testPrototypeFunction('findIndex', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.findIndex callback must be a function'");
    5252debug("");
    5353finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-forEach.js

    r190429 r191300  
    8383
    8484debug("5.0 Wrong Type for Callback Test");
    85 shouldThrow("testPrototypeFunction('forEach', '(8)', [12, 15, 10, 13, 44], false)");
    86 shouldThrow("testPrototypeFunction('forEach', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    87 shouldThrow("testPrototypeFunction('forEach', '(new Object())', [12, 15, 10, 13, 44], false)");
    88 shouldThrow("testPrototypeFunction('forEach', '(null)', [12, 15, 10, 13, 44], false)");
    89 shouldThrow("testPrototypeFunction('forEach', '()', [12, 15, 10, 13, 44], false)");
     85shouldThrow("testPrototypeFunction('forEach', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.forEach callback must be a function'");
     86shouldThrow("testPrototypeFunction('forEach', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.forEach callback must be a function'");
     87shouldThrow("testPrototypeFunction('forEach', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.forEach callback must be a function'");
     88shouldThrow("testPrototypeFunction('forEach', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.forEach callback must be a function'");
     89shouldThrow("testPrototypeFunction('forEach', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.forEach callback must be a function'");
    9090debug("");
    9191finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-map.js

    r190429 r191300  
    4343
    4444debug("5.0 Wrong Type for Callback Test");
    45 shouldThrow("testPrototypeFunction('map', '(8)', [12, 15, 10, 13, 44], false)");
    46 shouldThrow("testPrototypeFunction('map', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    47 shouldThrow("testPrototypeFunction('map', '(new Object())', [12, 15, 10, 13, 44], false)");
    48 shouldThrow("testPrototypeFunction('map', '(null)', [12, 15, 10, 13, 44], false)");
    49 shouldThrow("testPrototypeFunction('map', '()', [12, 15, 10, 13, 44], false)");
     45shouldThrow("testPrototypeFunction('map', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.map callback must be a function'");
     46shouldThrow("testPrototypeFunction('map', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.map callback must be a function'");
     47shouldThrow("testPrototypeFunction('map', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.map callback must be a function'");
     48shouldThrow("testPrototypeFunction('map', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.map callback must be a function'");
     49shouldThrow("testPrototypeFunction('map', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.map callback must be a function'");
    5050debug("");
    5151finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-reduce.js

    r190429 r191300  
    5050
    5151debug("5.0 Wrong Type for Callback Test");
    52 shouldThrow("testPrototypeFunction('reduce', '(8)', [12, 15, 10, 13, 44], false)");
    53 shouldThrow("testPrototypeFunction('reduce', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    54 shouldThrow("testPrototypeFunction('reduce', '(new Object())', [12, 15, 10, 13, 44], false)");
    55 shouldThrow("testPrototypeFunction('reduce', '(null)', [12, 15, 10, 13, 44], false)");
    56 shouldThrow("testPrototypeFunction('reduce', '()', [12, 15, 10, 13, 44], false)");
     52shouldThrow("testPrototypeFunction('reduce', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduce callback must be a function'");
     53shouldThrow("testPrototypeFunction('reduce', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduce callback must be a function'");
     54shouldThrow("testPrototypeFunction('reduce', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduce callback must be a function'");
     55shouldThrow("testPrototypeFunction('reduce', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduce callback must be a function'");
     56shouldThrow("testPrototypeFunction('reduce', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduce callback must be a function'");
     57shouldThrow("testPrototypeFunction('reduce', '(new Function())', [], false)", "'TypeError: TypedArray.prototype.reduce of empty array with no initial value'");
    5758debug("");
    5859finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-reduceRight.js

    r190429 r191300  
    5050
    5151debug("5.0 Wrong Type for Callback Test");
    52 shouldThrow("testPrototypeFunction('reduceRight', '(8)', [12, 15, 10, 13, 44], false)");
    53 shouldThrow("testPrototypeFunction('reduceRight', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    54 shouldThrow("testPrototypeFunction('reduceRight', '(new Object())', [12, 15, 10, 13, 44], false)");
    55 shouldThrow("testPrototypeFunction('reduceRight', '(null)', [12, 15, 10, 13, 44], false)");
    56 shouldThrow("testPrototypeFunction('reduceRight', '()', [12, 15, 10, 13, 44], false)");
     52shouldThrow("testPrototypeFunction('reduceRight', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduceRight callback must be a function'");
     53shouldThrow("testPrototypeFunction('reduceRight', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduceRight callback must be a function'");
     54shouldThrow("testPrototypeFunction('reduceRight', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduceRight callback must be a function'");
     55shouldThrow("testPrototypeFunction('reduceRight', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduceRight callback must be a function'");
     56shouldThrow("testPrototypeFunction('reduceRight', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.reduceRight callback must be a function'");
     57shouldThrow("testPrototypeFunction('reduceRight', '(new Function())', [], false)", "'TypeError: TypedArray.prototype.reduceRight of empty array with no initial value'");
    5758debug("");
    5859finishJSTest();
  • trunk/Source/JavaScriptCore/tests/stress/typedarray-some.js

    r190429 r191300  
    4848
    4949debug("5.0 Wrong Type for Callback Test");
    50 shouldThrow("testPrototypeFunction('some', '(8)', [12, 15, 10, 13, 44], false)");
    51 shouldThrow("testPrototypeFunction('some', '(\"wrong\")', [12, 15, 10, 13, 44], false)");
    52 shouldThrow("testPrototypeFunction('some', '(new Object())', [12, 15, 10, 13, 44], false)");
    53 shouldThrow("testPrototypeFunction('some', '(null)', [12, 15, 10, 13, 44], false)");
    54 shouldThrow("testPrototypeFunction('some', '()', [12, 15, 10, 13, 44], false)");
     50shouldThrow("testPrototypeFunction('some', '(8)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.some callback must be a function'");
     51shouldThrow("testPrototypeFunction('some', '(\"wrong\")', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.some callback must be a function'");
     52shouldThrow("testPrototypeFunction('some', '(new Object())', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.some callback must be a function'");
     53shouldThrow("testPrototypeFunction('some', '(null)', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.some callback must be a function'");
     54shouldThrow("testPrototypeFunction('some', '()', [12, 15, 10, 13, 44], false)", "'TypeError: TypedArray.prototype.some callback must be a function'");
    5555debug("");
    5656finishJSTest();
Note: See TracChangeset for help on using the changeset viewer.