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

Side by Side Diff: test/mjsunit/string-charcodeat.js

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 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 | « test/mjsunit/strict-mode-eval.js ('k') | test/mjsunit/testcfg.py » ('j') | no next file with comments »
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 TestStringType(Flat, false); 146 TestStringType(Flat, false);
147 TestStringType(NotAString, false); 147 TestStringType(NotAString, false);
148 TestStringType(Cons16, true); 148 TestStringType(Cons16, true);
149 TestStringType(Deep16, true); 149 TestStringType(Deep16, true);
150 TestStringType(Slice16Beginning, true); 150 TestStringType(Slice16Beginning, true);
151 TestStringType(Slice16Middle, true); 151 TestStringType(Slice16Middle, true);
152 TestStringType(Slice16End, true); 152 TestStringType(Slice16End, true);
153 TestStringType(Flat16, true); 153 TestStringType(Flat16, true);
154 TestStringType(NotAString16, true); 154 TestStringType(NotAString16, true);
155 155
156
157 function ConsNotSmiIndex() {
158 var str = Cons();
159 assertTrue(isNaN(str.charCodeAt(0x7fffffff)));
160 }
161
162 for (var i = 0; i < 100000; i++) {
163 ConsNotSmiIndex();
164 }
165
166
156 for (var i = 0; i != 10; i++) { 167 for (var i = 0; i != 10; i++) {
157 assertEquals(101, Cons16().charCodeAt(1.1)); 168 assertEquals(101, Cons16().charCodeAt(1.1));
158 assertEquals('e', Cons16().charAt(1.1)); 169 assertEquals('e', Cons16().charAt(1.1));
159 } 170 }
160 171
161 function StupidThing() { 172 function StupidThing() {
162 // Doesn't return a string from toString! 173 // Doesn't return a string from toString!
163 this.toString = function() { return 42; } 174 this.toString = function() { return 42; }
164 this.charCodeAt = String.prototype.charCodeAt; 175 this.charCodeAt = String.prototype.charCodeAt;
165 } 176 }
(...skipping 21 matching lines...) Expand all
187 198
188 assertTrue(isNaN(medium.charCodeAt(-1)), 31); 199 assertTrue(isNaN(medium.charCodeAt(-1)), 31);
189 assertEquals(49, medium.charCodeAt(0), 32); 200 assertEquals(49, medium.charCodeAt(0), 32);
190 assertEquals(56, medium.charCodeAt(255), 33); 201 assertEquals(56, medium.charCodeAt(255), 33);
191 assertTrue(isNaN(medium.charCodeAt(256)), 34); 202 assertTrue(isNaN(medium.charCodeAt(256)), 34);
192 203
193 assertTrue(isNaN(long.charCodeAt(-1)), 35); 204 assertTrue(isNaN(long.charCodeAt(-1)), 35);
194 assertEquals(49, long.charCodeAt(0), 36); 205 assertEquals(49, long.charCodeAt(0), 36);
195 assertEquals(56, long.charCodeAt(65535), 37); 206 assertEquals(56, long.charCodeAt(65535), 37);
196 assertTrue(isNaN(long.charCodeAt(65536)), 38); 207 assertTrue(isNaN(long.charCodeAt(65536)), 38);
208
209
210 // Test crankshaft code when the function is set directly on the
211 // string prototype object instead of the hidden prototype object.
212 // See http://code.google.com/p/v8/issues/detail?id=1070
213
214 String.prototype.x = String.prototype.charCodeAt;
215
216 function directlyOnPrototype() {
217 assertEquals(97, "a".x(0));
218 assertEquals(98, "b".x(0));
219 assertEquals(99, "c".x(0));
220 assertEquals(97, "a".x(0));
221 assertEquals(98, "b".x(0));
222 assertEquals(99, "c".x(0));
223 }
224
225 for (var i = 0; i < 10000; i++) {
226 directlyOnPrototype();
227 }
OLDNEW
« no previous file with comments | « test/mjsunit/strict-mode-eval.js ('k') | test/mjsunit/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698