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

Side by Side Diff: test/mjsunit/apply.js

Issue 2835014: Make the apply.js unit test more resilient to differing stack positions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: enable test in .status; use booleans in test Created 10 years, 6 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 | test/mjsunit/mjsunit.status » ('j') | test/mjsunit/mjsunit.status » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return doo; 105 return doo;
106 } 106 }
107 107
108 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string"); 108 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string");
109 109
110 function al() { 110 function al() {
111 assertEquals(345, this); 111 assertEquals(345, this);
112 return arguments.length + arguments[arguments.length - 1]; 112 return arguments.length + arguments[arguments.length - 1];
113 } 113 }
114 114
115 var stack_corner_case_failure = false;
116
115 for (var j = 1; j < 0x40000000; j <<= 1) { 117 for (var j = 1; j < 0x40000000; j <<= 1) {
116 try { 118 try {
117 var a = new Array(j); 119 var a = new Array(j);
118 a[j - 1] = 42; 120 a[j - 1] = 42;
119 assertEquals(42 + j, al.apply(345, a)); 121 assertEquals(42 + j, al.apply(345, a));
120 } catch (e) { 122 } catch (e) {
123 if (e.toString().indexOf("Maximum call stack size exceeded") != -1) {
124 // For some combinations of build settings, it may be the case that the
125 // stack here is just tall enough to contain the array whose size is
126 // specified by j but is not tall enough to contain the activation
127 // record for the apply call. Allow one such corner case through,
128 // checking that the length check will do the right thing for an array
129 // the next size up.
130 assertEquals(false, stack_corner_case_failure);
131 stack_corner_case_failure = true;
132 continue;
133 }
121 assertTrue(e.toString().indexOf("Function.prototype.apply") != -1, 134 assertTrue(e.toString().indexOf("Function.prototype.apply") != -1,
122 "exception does not contain Function.prototype.apply: " + 135 "exception does not contain Function.prototype.apply: " +
123 e.toString()); 136 e.toString());
124 for (; j < 0x40000000; j <<= 1) { 137 for (; j < 0x40000000; j <<= 1) {
125 var caught = false; 138 var caught = false;
126 try { 139 try {
127 a = new Array(j); 140 a = new Array(j);
128 a[j - 1] = 42; 141 a[j - 1] = 42;
129 al.apply(345, a); 142 al.apply(345, a);
130 assertUnreachable("Apply of arrray with length " + a.length + 143 assertUnreachable("Apply of array with length " + a.length +
131 " should have thrown"); 144 " should have thrown");
132 } catch (e) { 145 } catch (e) {
133 assertTrue(e.toString().indexOf("Function.prototype.apply") != -1, 146 assertTrue(e.toString().indexOf("Function.prototype.apply") != -1,
134 "exception does not contain Function.prototype.apply [" + 147 "exception does not contain Function.prototype.apply [" +
135 "length = " + j + "]: " + e.toString()); 148 "length = " + j + "]: " + e.toString());
136 caught = true; 149 caught = true;
137 } 150 }
138 assertTrue(caught, "exception not caught"); 151 assertTrue(caught, "exception not caught");
139 } 152 }
140 break; 153 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 "morseper4"); 200 "morseper4");
188 201
189 primes[0] = ""; 202 primes[0] = "";
190 primes[1] = holey; 203 primes[1] = holey;
191 assertThrows("String.prototype.concat.apply.apply('foo', primes)"); 204 assertThrows("String.prototype.concat.apply.apply('foo', primes)");
192 assertEquals("morseper", 205 assertEquals("morseper",
193 String.prototype.concat.apply.apply(String.prototype.concat, primes), 206 String.prototype.concat.apply.apply(String.prototype.concat, primes),
194 "moreseper-prime"); 207 "moreseper-prime");
195 208
196 delete(Array.prototype["1"]); 209 delete(Array.prototype["1"]);
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | test/mjsunit/mjsunit.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698