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

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

Issue 559993005: Move configuration of ResourceConstraints to Isolate construction (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1202
1203 result = CompileRun(slice_from_slice); 1203 result = CompileRun(slice_from_slice);
1204 CHECK(result->IsString()); 1204 CHECK(result->IsString());
1205 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1205 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1206 CHECK(string->IsSlicedString()); 1206 CHECK(string->IsSlicedString());
1207 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1207 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1208 CHECK_EQ("cdefghijklmnopqrstuvwx", string->ToCString().get()); 1208 CHECK_EQ("cdefghijklmnopqrstuvwx", string->ToCString().get());
1209 } 1209 }
1210 1210
1211 1211
1212 TEST(OneByteArrayJoin) { 1212 UNINITIALIZED_TEST(OneByteArrayJoin) {
1213 v8::Isolate::CreateParams create_params;
1213 // Set heap limits. 1214 // Set heap limits.
1214 v8::ResourceConstraints constraints; 1215 create_params.constraints.set_max_semi_space_size(1);
1215 constraints.set_max_semi_space_size(1); 1216 create_params.constraints.set_max_old_space_size(4);
1216 constraints.set_max_old_space_size(4); 1217 v8::Isolate* isolate = v8::Isolate::New(create_params);
1217 v8::SetResourceConstraints(CcTest::isolate(), &constraints); 1218 isolate->Enter();
1218 1219
1219 // String s is made of 2^17 = 131072 'c' characters and a is an array 1220 {
1220 // starting with 'bad', followed by 2^14 times the string s. That means the 1221 // String s is made of 2^17 = 131072 'c' characters and a is an array
1221 // total length of the concatenated strings is 2^31 + 3. So on 32bit systems 1222 // starting with 'bad', followed by 2^14 times the string s. That means the
1222 // summing the lengths of the strings (as Smis) overflows and wraps. 1223 // total length of the concatenated strings is 2^31 + 3. So on 32bit systems
1223 LocalContext context; 1224 // summing the lengths of the strings (as Smis) overflows and wraps.
1224 v8::HandleScope scope(CcTest::isolate()); 1225 LocalContext context(isolate);
1225 v8::TryCatch try_catch; 1226 v8::HandleScope scope(isolate);
1226 CHECK(CompileRun( 1227 v8::TryCatch try_catch;
1227 "var two_14 = Math.pow(2, 14);" 1228 CHECK(CompileRun(
1228 "var two_17 = Math.pow(2, 17);" 1229 "var two_14 = Math.pow(2, 14);"
1229 "var s = Array(two_17 + 1).join('c');" 1230 "var two_17 = Math.pow(2, 17);"
1230 "var a = ['bad'];" 1231 "var s = Array(two_17 + 1).join('c');"
1231 "for (var i = 1; i <= two_14; i++) a.push(s);" 1232 "var a = ['bad'];"
1232 "a.join("");").IsEmpty()); 1233 "for (var i = 1; i <= two_14; i++) a.push(s);"
1233 CHECK(try_catch.HasCaught()); 1234 "a.join("
1235 ");").IsEmpty());
1236 CHECK(try_catch.HasCaught());
1237 }
1238 isolate->Exit();
1239 isolate->Dispose();
1234 } 1240 }
1235 1241
1236 1242
1237 static void CheckException(const char* source) { 1243 static void CheckException(const char* source) {
1238 // An empty handle is returned upon exception. 1244 // An empty handle is returned upon exception.
1239 CHECK(CompileRun(source).IsEmpty()); 1245 CHECK(CompileRun(source).IsEmpty());
1240 } 1246 }
1241 1247
1242 1248
1243 TEST(RobustSubStringStub) { 1249 TEST(RobustSubStringStub) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 CHECK(isolate->has_pending_exception()); \ 1419 CHECK(isolate->has_pending_exception()); \
1414 isolate->clear_pending_exception(); \ 1420 isolate->clear_pending_exception(); \
1415 dummy.Dispose(); \ 1421 dummy.Dispose(); \
1416 } 1422 }
1417 1423
1418 INVALID_STRING_TEST(NewStringFromAscii, char) 1424 INVALID_STRING_TEST(NewStringFromAscii, char)
1419 INVALID_STRING_TEST(NewStringFromUtf8, char) 1425 INVALID_STRING_TEST(NewStringFromUtf8, char)
1420 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t) 1426 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
1421 1427
1422 #undef INVALID_STRING_TEST 1428 #undef INVALID_STRING_TEST
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