Chromium Code Reviews| Index: test/mjsunit/function-call.js |
| =================================================================== |
| --- test/mjsunit/function-call.js (revision 0) |
| +++ test/mjsunit/function-call.js (revision 0) |
| @@ -0,0 +1,172 @@ |
| +// Copyright 2011 the V8 project authors. All rights reserved. |
|
Lasse Reichstein
2011/04/27 11:26:50
Put this file into mjsunit/bugs/bug-<bugnumber>.js
Rico
2011/04/27 13:17:54
I will implement this NOW.
|
| +// Redistribution and use in source and binary forms, with or without |
| +// modification, are permitted provided that the following conditions are |
| +// met: |
| +// |
| +// * Redistributions of source code must retain the above copyright |
| +// notice, this list of conditions and the following disclaimer. |
| +// * Redistributions in binary form must reproduce the above |
| +// copyright notice, this list of conditions and the following |
| +// disclaimer in the documentation and/or other materials provided |
| +// with the distribution. |
| +// * Neither the name of Google Inc. nor the names of its |
| +// contributors may be used to endorse or promote products derived |
| +// from this software without specific prior written permission. |
| +// |
| +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + |
| + |
| +var should_throw_on_null_and_undefined = |
| + ['Object.prototype.toLocaleString', |
|
Lasse Reichstein
2011/04/27 11:26:50
Just make this an array of the functions, not stri
Rico
2011/04/27 13:17:54
Done.
|
| + 'Object.prototype.valueOf', |
| + 'Object.prototype.hasOwnProperty', |
| + 'Object.prototype.isPrototypeOf', |
| + 'Object.prototype.propertyIsEnumerable', |
| + // Function.prototype.toString should throw on more than null |
| + // and undefined, but that is tested elsewhere. |
| + 'Function.prototype.toString', |
|
Lasse Reichstein
2011/04/27 11:26:50
Function.prototype.{call,apply,bind} also throw on
Rico
2011/04/27 13:17:54
As discussed offline I am adding these to a differ
|
| + 'Array.prototype.toString', |
| + 'Array.prototype.toLocaleString', |
| + 'Array.prototype.concat', |
| + 'Array.prototype.join', |
| + 'Array.prototype.pop', |
| + 'Array.prototype.push', |
| + 'Array.prototype.reverse', |
| + 'Array.prototype.shift', |
| + 'Array.prototype.slice', |
| + 'Array.prototype.sort', |
| + 'Array.prototype.splice', |
| + 'Array.prototype.unshift', |
| + 'Array.prototype.indexOf', |
| + 'Array.prototype.lastIndexOf', |
| + 'Array.prototype.every', |
| + 'Array.prototype.some', |
| + 'Array.prototype.forEach', |
| + 'Array.prototype.map', |
| + 'Array.prototype.filter', |
| + 'Array.prototype.reduce', |
| + 'Array.prototype.reduceRight', |
| + // String.prototype.toString and String.prototype.valueOf should |
| + // throw on more than null and undefined, but that is tested elsewhere. |
| + 'String.prototype.toString', |
| + 'String.prototype.valueOf', |
| + 'String.prototype.charAt', |
| + 'String.prototype.charCodeAt', |
| + 'String.prototype.concat', |
| + 'String.prototype.indexOf', |
| + 'String.prototype.lastIndexOf', |
| + 'String.prototype.localeCompare', |
| + 'String.prototype.match', |
| + 'String.prototype.replace', |
| + 'String.prototype.search', |
| + 'String.prototype.slice', |
| + 'String.prototype.split', |
| + 'String.prototype.substring', |
| + 'String.prototype.toLowerCase', |
| + 'String.prototype.toLocaleLowerCase', |
| + 'String.prototype.toUpperCase', |
| + 'String.prototype.toLocaleUpperCase', |
| + 'String.prototype.trim', |
| + // Boolean.prototype.toString and Boolean.prototype.valueOf should |
| + // throw on more than null and undefined, but that is tested elsewhere. |
| + 'Boolean.prototype.toString', |
| + 'Boolean.prototype.valueOf', |
| + // Number.prototype.toString and Number.prototype.valueOf should |
| + // throw on more than null and undefined, but that is tested elsewhere. |
| + 'Number.prototype.toString', |
| + 'Number.prototype.valueOf', |
| + 'Number.prototype.toLocaleString', |
| + // The following due to the the note under "Properties of the Number |
| + // Prototype Object". |
| + 'Number.prototype.toFixed', |
| + 'Number.prototype.toExponential', |
| + 'Number.prototype.toPrecision', |
| + // The following due to the the note under "Properties of the Date |
| + // Prototype Object". |
| + 'Date.prototype.toString', |
| + 'Date.prototype.toDateString', |
| + 'Date.prototype.toTimeString', |
| + 'Date.prototype.toLocaleString', |
| + 'Date.prototype.toLocaleDateString', |
| + 'Date.prototype.toLocaleTimeString', |
| + 'Date.prototype.valueOf', |
| + 'Date.prototype.getTime', |
| + 'Date.prototype.getFullYear', |
| + 'Date.prototype.getUTCFullYear', |
| + 'Date.prototype.getMonth', |
| + 'Date.prototype.getUTCMonth', |
| + 'Date.prototype.getDate', |
| + 'Date.prototype.getUTCDate', |
| + 'Date.prototype.getDay', |
| + 'Date.prototype.getUTCDay', |
| + 'Date.prototype.getHours', |
| + 'Date.prototype.getUTCHours', |
| + 'Date.prototype.getMinutes', |
| + 'Date.prototype.getUTCMinutes', |
| + 'Date.prototype.getSeconds', |
| + 'Date.prototype.getUTCSeconds', |
| + 'Date.prototype.getMilliseconds', |
| + 'Date.prototype.getUTCMilliseconds', |
| + 'Date.prototype.getTimezoneOffset', |
| + 'Date.prototype.setTime', |
| + 'Date.prototype.setMilliseconds', |
| + 'Date.prototype.setUTCMilliseconds', |
| + 'Date.prototype.setSeconds', |
| + 'Date.prototype.setUTCSeconds', |
| + 'Date.prototype.setMinutes', |
| + 'Date.prototype.setUTCMinutes', |
| + 'Date.prototype.setHours', |
| + 'Date.prototype.setUTCHours', |
| + 'Date.prototype.setDate', |
| + 'Date.prototype.setUTCDate', |
| + 'Date.prototype.setMonth', |
| + 'Date.prototype.setUTCMonth', |
| + 'Date.prototype.setFullYear', |
| + 'Date.prototype.setUTCFullYear', |
| + 'Date.prototype.toUTCString', |
| + 'Date.prototype.toISOString', |
| + 'Date.prototype.toJSON', |
| + // The following due to the the note under "Properties of the RegExp |
| + // Prototype Object". |
| + 'RegExp.prototype.exec', |
| + 'RegExp.prototype.test', |
| + 'RegExp.prototype.toString', |
|
Lasse Reichstein
2011/04/27 11:26:50
All Number, Date and RegExp methods are non-generi
Rico
2011/04/27 13:17:54
Again, I will still test this since the change to
|
| + 'Error.prototype.toString']; |
| + |
| + |
| +for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) { |
| + // Sanity check that all functions are correct |
| + assertTrue(eval('typeof(' + |
| + should_throw_on_null_and_undefined[i] + |
| + ') == "function"')); |
| + try { |
| + eval(should_throw_on_null_and_undefined[i] + '.call(null)'); |
|
Lasse Reichstein
2011/04/27 11:26:50
Check both .call and .apply.
Also consider checkin
Rico
2011/04/27 13:17:54
Done.
|
| + assertUnreachable(); |
| + } catch (e) { |
| + assertTrue(/called on non-object/.test(e)); |
| + } |
| + |
| + try { |
| + eval(should_throw_on_null_and_undefined[i] + '.call(undefined)'); |
| + assertUnreachable(); |
| + } catch (e) { |
| + assertTrue(/called on non-object/.test(e)); |
| + } |
| +} |
| + |
| +// Object.prototype.toString() |
| +assertEquals(Object.prototype.toString.call(null), |
| + '[object Null]') |
| + |
| +assertEquals(Object.prototype.toString.call(undefined), |
| + '[object Undefined]') |