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

Side by Side Diff: test/cctest/test-strings.cc

Issue 209903003: Reland "Remove Failure::OutOfMemory propagation and V8::IgnoreOutOfMemoryException." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 9 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/cctest/test-api.cc ('k') | 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
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1268 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1269 CHECK_EQ("cdefghijklmnopq", string->ToCString().get()); 1269 CHECK_EQ("cdefghijklmnopq", string->ToCString().get());
1270 1270
1271 // Test that out-of-bounds substring of a slice fails when the indices 1271 // Test that out-of-bounds substring of a slice fails when the indices
1272 // would have been valid for the underlying string. 1272 // would have been valid for the underlying string.
1273 CompileRun("var slice = long.slice(1, 15);"); 1273 CompileRun("var slice = long.slice(1, 15);");
1274 CheckException("%_SubString(slice, 0, 17);"); 1274 CheckException("%_SubString(slice, 0, 17);");
1275 } 1275 }
1276 1276
1277 1277
1278 TEST(RegExpOverflow) {
1279 // Result string has the length 2^32, causing a 32-bit integer overflow.
1280 CcTest::InitializeVM();
1281 v8::HandleScope scope(CcTest::isolate());
1282 LocalContext context;
1283 v8::V8::IgnoreOutOfMemoryException();
1284 v8::Local<v8::Value> result = CompileRun(
1285 "var a = 'a'; "
1286 "for (var i = 0; i < 16; i++) { "
1287 " a += a; "
1288 "} "
1289 "a.replace(/a/g, a); ");
1290 CHECK(result.IsEmpty());
1291 CHECK(context->HasOutOfMemoryException());
1292 }
1293
1294
1295 TEST(StringReplaceAtomTwoByteResult) { 1278 TEST(StringReplaceAtomTwoByteResult) {
1296 CcTest::InitializeVM(); 1279 CcTest::InitializeVM();
1297 v8::HandleScope scope(CcTest::isolate()); 1280 v8::HandleScope scope(CcTest::isolate());
1298 LocalContext context; 1281 LocalContext context;
1299 v8::Local<v8::Value> result = CompileRun( 1282 v8::Local<v8::Value> result = CompileRun(
1300 "var subject = 'ascii~only~string~'; " 1283 "var subject = 'ascii~only~string~'; "
1301 "var replace = '\x80'; " 1284 "var replace = '\x80'; "
1302 "subject.replace(/~/g, replace); "); 1285 "subject.replace(/~/g, replace); ");
1303 CHECK(result->IsString()); 1286 CHECK(result->IsString());
1304 Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1287 Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 CheckCanonicalEquivalence(c, test); 1345 CheckCanonicalEquivalence(c, test);
1363 continue; 1346 continue;
1364 } 1347 }
1365 if (upper != c && lower != c) { 1348 if (upper != c && lower != c) {
1366 CheckCanonicalEquivalence(c, test); 1349 CheckCanonicalEquivalence(c, test);
1367 continue; 1350 continue;
1368 } 1351 }
1369 CHECK_EQ(Min(upper, lower), test); 1352 CHECK_EQ(Min(upper, lower), test);
1370 } 1353 }
1371 } 1354 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698