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

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

Issue 101763003: Replace 'operator*' with explicit 'get' method on SmartPointer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reupload to make rietveld happy Created 7 years 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-reloc-info.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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 CHECK(result->IsString()); 1168 CHECK(result->IsString());
1169 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1169 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1170 CHECK(!string->IsSlicedString()); 1170 CHECK(!string->IsSlicedString());
1171 1171
1172 string = factory->NewSubString(string, 0, 26); 1172 string = factory->NewSubString(string, 0, 26);
1173 CHECK(!string->IsSlicedString()); 1173 CHECK(!string->IsSlicedString());
1174 result = CompileRun(crosscheck); 1174 result = CompileRun(crosscheck);
1175 CHECK(result->IsString()); 1175 CHECK(result->IsString());
1176 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1176 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1177 CHECK(string->IsSlicedString()); 1177 CHECK(string->IsSlicedString());
1178 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); 1178 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get());
1179 } 1179 }
1180 1180
1181 1181
1182 TEST(SliceFromSlice) { 1182 TEST(SliceFromSlice) {
1183 // This tests whether a slice that contains the entire parent string 1183 // This tests whether a slice that contains the entire parent string
1184 // actually creates a new string (it should not). 1184 // actually creates a new string (it should not).
1185 FLAG_string_slices = true; 1185 FLAG_string_slices = true;
1186 CcTest::InitializeVM(); 1186 CcTest::InitializeVM();
1187 v8::HandleScope scope(CcTest::isolate()); 1187 v8::HandleScope scope(CcTest::isolate());
1188 v8::Local<v8::Value> result; 1188 v8::Local<v8::Value> result;
1189 Handle<String> string; 1189 Handle<String> string;
1190 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; 1190 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
1191 const char* slice = "var slice = str.slice(1,-1); slice"; 1191 const char* slice = "var slice = str.slice(1,-1); slice";
1192 const char* slice_from_slice = "slice.slice(1,-1);"; 1192 const char* slice_from_slice = "slice.slice(1,-1);";
1193 1193
1194 CompileRun(init); 1194 CompileRun(init);
1195 result = CompileRun(slice); 1195 result = CompileRun(slice);
1196 CHECK(result->IsString()); 1196 CHECK(result->IsString());
1197 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1197 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1198 CHECK(string->IsSlicedString()); 1198 CHECK(string->IsSlicedString());
1199 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1199 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1200 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); 1200 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get());
1201 1201
1202 result = CompileRun(slice_from_slice); 1202 result = CompileRun(slice_from_slice);
1203 CHECK(result->IsString()); 1203 CHECK(result->IsString());
1204 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1204 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1205 CHECK(string->IsSlicedString()); 1205 CHECK(string->IsSlicedString());
1206 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1206 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1207 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); 1207 CHECK_EQ("cdefghijklmnopqrstuvwx", string->ToCString().get());
1208 } 1208 }
1209 1209
1210 1210
1211 TEST(AsciiArrayJoin) { 1211 TEST(AsciiArrayJoin) {
1212 // Set heap limits. 1212 // Set heap limits.
1213 static const int K = 1024; 1213 static const int K = 1024;
1214 v8::ResourceConstraints constraints; 1214 v8::ResourceConstraints constraints;
1215 constraints.set_max_young_space_size(256 * K); 1215 constraints.set_max_young_space_size(256 * K);
1216 constraints.set_max_old_space_size(4 * K * K); 1216 constraints.set_max_old_space_size(4 * K * K);
1217 v8::SetResourceConstraints(CcTest::isolate(), &constraints); 1217 v8::SetResourceConstraints(CcTest::isolate(), &constraints);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 CheckException("%_SubString(short, -1234, 5);"); 1262 CheckException("%_SubString(short, -1234, 5);");
1263 CheckException("%_SubString(short, 5, 2);"); 1263 CheckException("%_SubString(short, 5, 2);");
1264 // Special HeapNumbers. 1264 // Special HeapNumbers.
1265 CheckException("%_SubString(short, 1, Infinity);"); 1265 CheckException("%_SubString(short, 1, Infinity);");
1266 CheckException("%_SubString(short, NaN, 5);"); 1266 CheckException("%_SubString(short, NaN, 5);");
1267 // String arguments. 1267 // String arguments.
1268 CheckException("%_SubString(short, '2', '5');"); 1268 CheckException("%_SubString(short, '2', '5');");
1269 // Ordinary HeapNumbers can be handled (in runtime). 1269 // Ordinary HeapNumbers can be handled (in runtime).
1270 result = CompileRun("%_SubString(short, Math.sqrt(4), 5.1);"); 1270 result = CompileRun("%_SubString(short, Math.sqrt(4), 5.1);");
1271 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1271 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1272 CHECK_EQ("cde", *(string->ToCString())); 1272 CHECK_EQ("cde", string->ToCString().get());
1273 1273
1274 CompileRun("var long = 'abcdefghijklmnopqrstuvwxyz';"); 1274 CompileRun("var long = 'abcdefghijklmnopqrstuvwxyz';");
1275 // Invalid indices. 1275 // Invalid indices.
1276 CheckException("%_SubString(long, 0, 10000);"); 1276 CheckException("%_SubString(long, 0, 10000);");
1277 CheckException("%_SubString(long, -1234, 17);"); 1277 CheckException("%_SubString(long, -1234, 17);");
1278 CheckException("%_SubString(long, 17, 2);"); 1278 CheckException("%_SubString(long, 17, 2);");
1279 // Special HeapNumbers. 1279 // Special HeapNumbers.
1280 CheckException("%_SubString(long, 1, Infinity);"); 1280 CheckException("%_SubString(long, 1, Infinity);");
1281 CheckException("%_SubString(long, NaN, 17);"); 1281 CheckException("%_SubString(long, NaN, 17);");
1282 // String arguments. 1282 // String arguments.
1283 CheckException("%_SubString(long, '2', '17');"); 1283 CheckException("%_SubString(long, '2', '17');");
1284 // Ordinary HeapNumbers within bounds can be handled (in runtime). 1284 // Ordinary HeapNumbers within bounds can be handled (in runtime).
1285 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);"); 1285 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);");
1286 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1286 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1287 CHECK_EQ("cdefghijklmnopq", *(string->ToCString())); 1287 CHECK_EQ("cdefghijklmnopq", string->ToCString().get());
1288 1288
1289 // Test that out-of-bounds substring of a slice fails when the indices 1289 // Test that out-of-bounds substring of a slice fails when the indices
1290 // would have been valid for the underlying string. 1290 // would have been valid for the underlying string.
1291 CompileRun("var slice = long.slice(1, 15);"); 1291 CompileRun("var slice = long.slice(1, 15);");
1292 CheckException("%_SubString(slice, 0, 17);"); 1292 CheckException("%_SubString(slice, 0, 17);");
1293 } 1293 }
1294 1294
1295 1295
1296 TEST(RegExpOverflow) { 1296 TEST(RegExpOverflow) {
1297 // Result string has the length 2^32, causing a 32-bit integer overflow. 1297 // Result string has the length 2^32, causing a 32-bit integer overflow.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 CheckCanonicalEquivalence(c, test); 1380 CheckCanonicalEquivalence(c, test);
1381 continue; 1381 continue;
1382 } 1382 }
1383 if (upper != c && lower != c) { 1383 if (upper != c && lower != c) {
1384 CheckCanonicalEquivalence(c, test); 1384 CheckCanonicalEquivalence(c, test);
1385 continue; 1385 continue;
1386 } 1386 }
1387 CHECK_EQ(Min(upper, lower), test); 1387 CHECK_EQ(Min(upper, lower), test);
1388 } 1388 }
1389 } 1389 }
OLDNEW
« no previous file with comments | « test/cctest/test-reloc-info.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698