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

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

Issue 725293003: don't use to-be-deprecated Value::To* without isolate parameter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « test/cctest/test-serialize.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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 CHECK_EQ(0, CompileRun(source)->Int32Value()); 1013 CHECK_EQ(0, CompileRun(source)->Int32Value());
1014 } 1014 }
1015 1015
1016 1016
1017 TEST(JSONStringifySliceMadeExternal) { 1017 TEST(JSONStringifySliceMadeExternal) {
1018 CcTest::InitializeVM(); 1018 CcTest::InitializeVM();
1019 // Create a sliced string from a one-byte string. The latter is turned 1019 // Create a sliced string from a one-byte string. The latter is turned
1020 // into a two-byte external string. Check that JSON.stringify works. 1020 // into a two-byte external string. Check that JSON.stringify works.
1021 v8::HandleScope handle_scope(CcTest::isolate()); 1021 v8::HandleScope handle_scope(CcTest::isolate());
1022 v8::Handle<v8::String> underlying = 1022 v8::Handle<v8::String> underlying =
1023 CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';" 1023 CompileRun(
1024 "underlying")->ToString(); 1024 "var underlying = 'abcdefghijklmnopqrstuvwxyz';"
1025 v8::Handle<v8::String> slice = 1025 "underlying")->ToString(CcTest::isolate());
1026 CompileRun("var slice = underlying.slice(1);" 1026 v8::Handle<v8::String> slice = CompileRun(
1027 "slice")->ToString(); 1027 "var slice = underlying.slice(1);"
1028 "slice")->ToString(CcTest::isolate());
1028 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); 1029 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1029 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString()); 1030 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
1030 1031
1031 int length = underlying->Length(); 1032 int length = underlying->Length();
1032 uc16* two_byte = NewArray<uc16>(length + 1); 1033 uc16* two_byte = NewArray<uc16>(length + 1);
1033 underlying->Write(two_byte); 1034 underlying->Write(two_byte);
1034 Resource* resource = new Resource(two_byte, length); 1035 Resource* resource = new Resource(two_byte, length);
1035 CHECK(underlying->MakeExternal(resource)); 1036 CHECK(underlying->MakeExternal(resource));
1036 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); 1037 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1037 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString()); 1038 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1076
1076 const char* line; 1077 const char* line;
1077 for (int i = 0; (line = lines[i]); i++) { 1078 for (int i = 0; (line = lines[i]); i++) {
1078 printf("%s\n", line); 1079 printf("%s\n", line);
1079 v8::Local<v8::Value> result = v8::Script::Compile( 1080 v8::Local<v8::Value> result = v8::Script::Compile(
1080 v8::String::NewFromUtf8(CcTest::isolate(), line))->Run(); 1081 v8::String::NewFromUtf8(CcTest::isolate(), line))->Run();
1081 CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined()); 1082 CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined());
1082 CHECK_EQ(results[i]->IsNumber(), result->IsNumber()); 1083 CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
1083 if (result->IsNumber()) { 1084 if (result->IsNumber()) {
1084 CHECK_EQ(Object::ToSmi(isolate, results[i]).ToHandleChecked()->value(), 1085 CHECK_EQ(Object::ToSmi(isolate, results[i]).ToHandleChecked()->value(),
1085 result->ToInt32()->Value()); 1086 result->ToInt32(CcTest::isolate())->Value());
1086 } 1087 }
1087 } 1088 }
1088 } 1089 }
1089 1090
1090 1091
1091 TEST(SliceFromCons) { 1092 TEST(SliceFromCons) {
1092 FLAG_string_slices = true; 1093 FLAG_string_slices = true;
1093 CcTest::InitializeVM(); 1094 CcTest::InitializeVM();
1094 Factory* factory = CcTest::i_isolate()->factory(); 1095 Factory* factory = CcTest::i_isolate()->factory();
1095 v8::HandleScope scope(CcTest::isolate()); 1096 v8::HandleScope scope(CcTest::isolate());
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 CHECK_EQ(0, use_counts[v8::Isolate::kBreakIterator]); 1307 CHECK_EQ(0, use_counts[v8::Isolate::kBreakIterator]);
1307 v8::Local<v8::Value> result = CompileRun( 1308 v8::Local<v8::Value> result = CompileRun(
1308 "(function() {" 1309 "(function() {"
1309 " if (!this.Intl) return 0;" 1310 " if (!this.Intl) return 0;"
1310 " var iterator = Intl.v8BreakIterator(['en']);" 1311 " var iterator = Intl.v8BreakIterator(['en']);"
1311 " iterator.adoptText('Now is the time');" 1312 " iterator.adoptText('Now is the time');"
1312 " iterator.next();" 1313 " iterator.next();"
1313 " return iterator.next();" 1314 " return iterator.next();"
1314 "})();"); 1315 "})();");
1315 CHECK(result->IsNumber()); 1316 CHECK(result->IsNumber());
1316 int uses = result->ToInt32()->Value() == 0 ? 0 : 1; 1317 int uses = result->ToInt32(CcTest::isolate())->Value() == 0 ? 0 : 1;
1317 CHECK_EQ(uses, use_counts[v8::Isolate::kBreakIterator]); 1318 CHECK_EQ(uses, use_counts[v8::Isolate::kBreakIterator]);
1318 // Make sure GC cleans up the break iterator, so we don't get a memory leak 1319 // Make sure GC cleans up the break iterator, so we don't get a memory leak
1319 // reported by ASAN. 1320 // reported by ASAN.
1320 CcTest::isolate()->LowMemoryNotification(); 1321 CcTest::isolate()->LowMemoryNotification();
1321 } 1322 }
1322 1323
1323 1324
1324 TEST(StringReplaceAtomTwoByteResult) { 1325 TEST(StringReplaceAtomTwoByteResult) {
1325 CcTest::InitializeVM(); 1326 CcTest::InitializeVM();
1326 v8::HandleScope scope(CcTest::isolate()); 1327 v8::HandleScope scope(CcTest::isolate());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 CHECK(isolate->has_pending_exception()); \ 1449 CHECK(isolate->has_pending_exception()); \
1449 isolate->clear_pending_exception(); \ 1450 isolate->clear_pending_exception(); \
1450 dummy.Dispose(); \ 1451 dummy.Dispose(); \
1451 } 1452 }
1452 1453
1453 INVALID_STRING_TEST(NewStringFromAscii, char) 1454 INVALID_STRING_TEST(NewStringFromAscii, char)
1454 INVALID_STRING_TEST(NewStringFromUtf8, char) 1455 INVALID_STRING_TEST(NewStringFromUtf8, char)
1455 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t) 1456 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
1456 1457
1457 #undef INVALID_STRING_TEST 1458 #undef INVALID_STRING_TEST
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698