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

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

Issue 893533003: Revert "Make GCC happy again." and "Initial switch to Chromium-style CHECK_* and DCHECK_* macros.". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-symbols.cc » ('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 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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString()); 1031 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
1032 1032
1033 int length = underlying->Length(); 1033 int length = underlying->Length();
1034 uc16* two_byte = NewArray<uc16>(length + 1); 1034 uc16* two_byte = NewArray<uc16>(length + 1);
1035 underlying->Write(two_byte); 1035 underlying->Write(two_byte);
1036 Resource* resource = new Resource(two_byte, length); 1036 Resource* resource = new Resource(two_byte, length);
1037 CHECK(underlying->MakeExternal(resource)); 1037 CHECK(underlying->MakeExternal(resource));
1038 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); 1038 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1039 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString()); 1039 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString());
1040 1040
1041 CHECK_EQ(0, 1041 CHECK_EQ("\"bcdefghijklmnopqrstuvwxyz\"",
1042 strcmp("\"bcdefghijklmnopqrstuvwxyz\"", 1042 *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)")));
1043 *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)"))));
1044 } 1043 }
1045 1044
1046 1045
1047 TEST(CachedHashOverflow) { 1046 TEST(CachedHashOverflow) {
1048 CcTest::InitializeVM(); 1047 CcTest::InitializeVM();
1049 // We incorrectly allowed strings to be tagged as array indices even if their 1048 // We incorrectly allowed strings to be tagged as array indices even if their
1050 // values didn't fit in the hash field. 1049 // values didn't fit in the hash field.
1051 // See http://code.google.com/p/v8/issues/detail?id=728 1050 // See http://code.google.com/p/v8/issues/detail?id=728
1052 Isolate* isolate = CcTest::i_isolate(); 1051 Isolate* isolate = CcTest::i_isolate();
1053 1052
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 CHECK(result->IsString()); 1164 CHECK(result->IsString());
1166 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1165 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1167 CHECK(!string->IsSlicedString()); 1166 CHECK(!string->IsSlicedString());
1168 1167
1169 string = factory->NewSubString(string, 0, 26); 1168 string = factory->NewSubString(string, 0, 26);
1170 CHECK(!string->IsSlicedString()); 1169 CHECK(!string->IsSlicedString());
1171 result = CompileRun(crosscheck); 1170 result = CompileRun(crosscheck);
1172 CHECK(result->IsString()); 1171 CHECK(result->IsString());
1173 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1172 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1174 CHECK(string->IsSlicedString()); 1173 CHECK(string->IsSlicedString());
1175 CHECK_EQ(0, strcmp("bcdefghijklmnopqrstuvwxy", string->ToCString().get())); 1174 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get());
1176 } 1175 }
1177 1176
1178 1177
1179 TEST(SliceFromSlice) { 1178 TEST(SliceFromSlice) {
1180 // This tests whether a slice that contains the entire parent string 1179 // This tests whether a slice that contains the entire parent string
1181 // actually creates a new string (it should not). 1180 // actually creates a new string (it should not).
1182 FLAG_string_slices = true; 1181 FLAG_string_slices = true;
1183 CcTest::InitializeVM(); 1182 CcTest::InitializeVM();
1184 v8::HandleScope scope(CcTest::isolate()); 1183 v8::HandleScope scope(CcTest::isolate());
1185 v8::Local<v8::Value> result; 1184 v8::Local<v8::Value> result;
1186 Handle<String> string; 1185 Handle<String> string;
1187 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; 1186 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
1188 const char* slice = "var slice = ''; slice = str.slice(1,-1); slice"; 1187 const char* slice = "var slice = ''; slice = str.slice(1,-1); slice";
1189 const char* slice_from_slice = "slice.slice(1,-1);"; 1188 const char* slice_from_slice = "slice.slice(1,-1);";
1190 1189
1191 CompileRun(init); 1190 CompileRun(init);
1192 result = CompileRun(slice); 1191 result = CompileRun(slice);
1193 CHECK(result->IsString()); 1192 CHECK(result->IsString());
1194 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1193 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1195 CHECK(string->IsSlicedString()); 1194 CHECK(string->IsSlicedString());
1196 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1195 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1197 CHECK_EQ(0, strcmp("bcdefghijklmnopqrstuvwxy", string->ToCString().get())); 1196 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get());
1198 1197
1199 result = CompileRun(slice_from_slice); 1198 result = CompileRun(slice_from_slice);
1200 CHECK(result->IsString()); 1199 CHECK(result->IsString());
1201 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1200 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1202 CHECK(string->IsSlicedString()); 1201 CHECK(string->IsSlicedString());
1203 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1202 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1204 CHECK_EQ(0, strcmp("cdefghijklmnopqrstuvwx", string->ToCString().get())); 1203 CHECK_EQ("cdefghijklmnopqrstuvwx", string->ToCString().get());
1205 } 1204 }
1206 1205
1207 1206
1208 UNINITIALIZED_TEST(OneByteArrayJoin) { 1207 UNINITIALIZED_TEST(OneByteArrayJoin) {
1209 v8::Isolate::CreateParams create_params; 1208 v8::Isolate::CreateParams create_params;
1210 // Set heap limits. 1209 // Set heap limits.
1211 create_params.constraints.set_max_semi_space_size(1); 1210 create_params.constraints.set_max_semi_space_size(1);
1212 create_params.constraints.set_max_old_space_size(4); 1211 create_params.constraints.set_max_old_space_size(4);
1213 v8::Isolate* isolate = v8::Isolate::New(create_params); 1212 v8::Isolate* isolate = v8::Isolate::New(create_params);
1214 isolate->Enter(); 1213 isolate->Enter();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 CheckException("%_SubString(short, -1234, 5);"); 1256 CheckException("%_SubString(short, -1234, 5);");
1258 CheckException("%_SubString(short, 5, 2);"); 1257 CheckException("%_SubString(short, 5, 2);");
1259 // Special HeapNumbers. 1258 // Special HeapNumbers.
1260 CheckException("%_SubString(short, 1, Infinity);"); 1259 CheckException("%_SubString(short, 1, Infinity);");
1261 CheckException("%_SubString(short, NaN, 5);"); 1260 CheckException("%_SubString(short, NaN, 5);");
1262 // String arguments. 1261 // String arguments.
1263 CheckException("%_SubString(short, '2', '5');"); 1262 CheckException("%_SubString(short, '2', '5');");
1264 // Ordinary HeapNumbers can be handled (in runtime). 1263 // Ordinary HeapNumbers can be handled (in runtime).
1265 result = CompileRun("%_SubString(short, Math.sqrt(4), 5.1);"); 1264 result = CompileRun("%_SubString(short, Math.sqrt(4), 5.1);");
1266 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1265 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1267 CHECK_EQ(0, strcmp("cde", string->ToCString().get())); 1266 CHECK_EQ("cde", string->ToCString().get());
1268 1267
1269 CompileRun("var long = 'abcdefghijklmnopqrstuvwxyz';"); 1268 CompileRun("var long = 'abcdefghijklmnopqrstuvwxyz';");
1270 // Invalid indices. 1269 // Invalid indices.
1271 CheckException("%_SubString(long, 0, 10000);"); 1270 CheckException("%_SubString(long, 0, 10000);");
1272 CheckException("%_SubString(long, -1234, 17);"); 1271 CheckException("%_SubString(long, -1234, 17);");
1273 CheckException("%_SubString(long, 17, 2);"); 1272 CheckException("%_SubString(long, 17, 2);");
1274 // Special HeapNumbers. 1273 // Special HeapNumbers.
1275 CheckException("%_SubString(long, 1, Infinity);"); 1274 CheckException("%_SubString(long, 1, Infinity);");
1276 CheckException("%_SubString(long, NaN, 17);"); 1275 CheckException("%_SubString(long, NaN, 17);");
1277 // String arguments. 1276 // String arguments.
1278 CheckException("%_SubString(long, '2', '17');"); 1277 CheckException("%_SubString(long, '2', '17');");
1279 // Ordinary HeapNumbers within bounds can be handled (in runtime). 1278 // Ordinary HeapNumbers within bounds can be handled (in runtime).
1280 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);"); 1279 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);");
1281 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1280 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1282 CHECK_EQ(0, strcmp("cdefghijklmnopq", string->ToCString().get())); 1281 CHECK_EQ("cdefghijklmnopq", string->ToCString().get());
1283 1282
1284 // Test that out-of-bounds substring of a slice fails when the indices 1283 // Test that out-of-bounds substring of a slice fails when the indices
1285 // would have been valid for the underlying string. 1284 // would have been valid for the underlying string.
1286 CompileRun("var slice = long.slice(1, 15);"); 1285 CompileRun("var slice = long.slice(1, 15);");
1287 CheckException("%_SubString(slice, 0, 17);"); 1286 CheckException("%_SubString(slice, 0, 17);");
1288 } 1287 }
1289 1288
1290 1289
1291 namespace { 1290 namespace {
1292 1291
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 CHECK(isolate->has_pending_exception()); \ 1451 CHECK(isolate->has_pending_exception()); \
1453 isolate->clear_pending_exception(); \ 1452 isolate->clear_pending_exception(); \
1454 dummy.Dispose(); \ 1453 dummy.Dispose(); \
1455 } 1454 }
1456 1455
1457 INVALID_STRING_TEST(NewStringFromAscii, char) 1456 INVALID_STRING_TEST(NewStringFromAscii, char)
1458 INVALID_STRING_TEST(NewStringFromUtf8, char) 1457 INVALID_STRING_TEST(NewStringFromUtf8, char)
1459 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t) 1458 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
1460 1459
1461 #undef INVALID_STRING_TEST 1460 #undef INVALID_STRING_TEST
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698