Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: test/mjsunit/function-call.js

Issue 6904047: Test to ensure .call on native functions work correctly when passed (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29 var should_throw_on_null_and_undefined =
30 ['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.
31 'Object.prototype.valueOf',
32 'Object.prototype.hasOwnProperty',
33 'Object.prototype.isPrototypeOf',
34 'Object.prototype.propertyIsEnumerable',
35 // Function.prototype.toString should throw on more than null
36 // and undefined, but that is tested elsewhere.
37 '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
38 'Array.prototype.toString',
39 'Array.prototype.toLocaleString',
40 'Array.prototype.concat',
41 'Array.prototype.join',
42 'Array.prototype.pop',
43 'Array.prototype.push',
44 'Array.prototype.reverse',
45 'Array.prototype.shift',
46 'Array.prototype.slice',
47 'Array.prototype.sort',
48 'Array.prototype.splice',
49 'Array.prototype.unshift',
50 'Array.prototype.indexOf',
51 'Array.prototype.lastIndexOf',
52 'Array.prototype.every',
53 'Array.prototype.some',
54 'Array.prototype.forEach',
55 'Array.prototype.map',
56 'Array.prototype.filter',
57 'Array.prototype.reduce',
58 'Array.prototype.reduceRight',
59 // String.prototype.toString and String.prototype.valueOf should
60 // throw on more than null and undefined, but that is tested elsewhere.
61 'String.prototype.toString',
62 'String.prototype.valueOf',
63 'String.prototype.charAt',
64 'String.prototype.charCodeAt',
65 'String.prototype.concat',
66 'String.prototype.indexOf',
67 'String.prototype.lastIndexOf',
68 'String.prototype.localeCompare',
69 'String.prototype.match',
70 'String.prototype.replace',
71 'String.prototype.search',
72 'String.prototype.slice',
73 'String.prototype.split',
74 'String.prototype.substring',
75 'String.prototype.toLowerCase',
76 'String.prototype.toLocaleLowerCase',
77 'String.prototype.toUpperCase',
78 'String.prototype.toLocaleUpperCase',
79 'String.prototype.trim',
80 // Boolean.prototype.toString and Boolean.prototype.valueOf should
81 // throw on more than null and undefined, but that is tested elsewhere.
82 'Boolean.prototype.toString',
83 'Boolean.prototype.valueOf',
84 // Number.prototype.toString and Number.prototype.valueOf should
85 // throw on more than null and undefined, but that is tested elsewhere.
86 'Number.prototype.toString',
87 'Number.prototype.valueOf',
88 'Number.prototype.toLocaleString',
89 // The following due to the the note under "Properties of the Number
90 // Prototype Object".
91 'Number.prototype.toFixed',
92 'Number.prototype.toExponential',
93 'Number.prototype.toPrecision',
94 // The following due to the the note under "Properties of the Date
95 // Prototype Object".
96 'Date.prototype.toString',
97 'Date.prototype.toDateString',
98 'Date.prototype.toTimeString',
99 'Date.prototype.toLocaleString',
100 'Date.prototype.toLocaleDateString',
101 'Date.prototype.toLocaleTimeString',
102 'Date.prototype.valueOf',
103 'Date.prototype.getTime',
104 'Date.prototype.getFullYear',
105 'Date.prototype.getUTCFullYear',
106 'Date.prototype.getMonth',
107 'Date.prototype.getUTCMonth',
108 'Date.prototype.getDate',
109 'Date.prototype.getUTCDate',
110 'Date.prototype.getDay',
111 'Date.prototype.getUTCDay',
112 'Date.prototype.getHours',
113 'Date.prototype.getUTCHours',
114 'Date.prototype.getMinutes',
115 'Date.prototype.getUTCMinutes',
116 'Date.prototype.getSeconds',
117 'Date.prototype.getUTCSeconds',
118 'Date.prototype.getMilliseconds',
119 'Date.prototype.getUTCMilliseconds',
120 'Date.prototype.getTimezoneOffset',
121 'Date.prototype.setTime',
122 'Date.prototype.setMilliseconds',
123 'Date.prototype.setUTCMilliseconds',
124 'Date.prototype.setSeconds',
125 'Date.prototype.setUTCSeconds',
126 'Date.prototype.setMinutes',
127 'Date.prototype.setUTCMinutes',
128 'Date.prototype.setHours',
129 'Date.prototype.setUTCHours',
130 'Date.prototype.setDate',
131 'Date.prototype.setUTCDate',
132 'Date.prototype.setMonth',
133 'Date.prototype.setUTCMonth',
134 'Date.prototype.setFullYear',
135 'Date.prototype.setUTCFullYear',
136 'Date.prototype.toUTCString',
137 'Date.prototype.toISOString',
138 'Date.prototype.toJSON',
139 // The following due to the the note under "Properties of the RegExp
140 // Prototype Object".
141 'RegExp.prototype.exec',
142 'RegExp.prototype.test',
143 '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
144 'Error.prototype.toString'];
145
146
147 for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
148 // Sanity check that all functions are correct
149 assertTrue(eval('typeof(' +
150 should_throw_on_null_and_undefined[i] +
151 ') == "function"'));
152 try {
153 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.
154 assertUnreachable();
155 } catch (e) {
156 assertTrue(/called on non-object/.test(e));
157 }
158
159 try {
160 eval(should_throw_on_null_and_undefined[i] + '.call(undefined)');
161 assertUnreachable();
162 } catch (e) {
163 assertTrue(/called on non-object/.test(e));
164 }
165 }
166
167 // Object.prototype.toString()
168 assertEquals(Object.prototype.toString.call(null),
169 '[object Null]')
170
171 assertEquals(Object.prototype.toString.call(undefined),
172 '[object Undefined]')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698