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

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

Issue 24704005: Merged r16393 into 3.20 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.20
Patch Set: Created 7 years, 2 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-heap.cc ('k') | test/mjsunit/allocation-folding.js » ('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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 " (non_ascii[j] + external_non_ascii[i - j])) return 12;" 1010 " (non_ascii[j] + external_non_ascii[i - j])) return 12;"
1011 " }" 1011 " }"
1012 " }" 1012 " }"
1013 " return 0;" 1013 " return 0;"
1014 "};" 1014 "};"
1015 "test()"; 1015 "test()";
1016 CHECK_EQ(0, CompileRun(source)->Int32Value()); 1016 CHECK_EQ(0, CompileRun(source)->Int32Value());
1017 } 1017 }
1018 1018
1019 1019
1020 TEST(JSONStringifySliceMadeExternal) {
1021 Isolate* isolate = Isolate::Current();
1022 Zone zone(isolate);
1023 CcTest::InitializeVM();
1024 // Create a sliced string from a one-byte string. The latter is turned
1025 // into a two-byte external string. Check that JSON.stringify works.
1026 v8::HandleScope handle_scope(CcTest::isolate());
1027 v8::Handle<v8::String> underlying =
1028 CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';"
1029 "underlying")->ToString();
1030 v8::Handle<v8::String> slice =
1031 CompileRun("var slice = underlying.slice(1);"
1032 "slice")->ToString();
1033 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1034 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
1035
1036 int length = underlying->Length();
1037 uc16* two_byte = zone.NewArray<uc16>(length + 1);
1038 underlying->Write(two_byte);
1039 Resource* resource =
1040 new(&zone) Resource(Vector<const uc16>(two_byte, length));
1041 CHECK(underlying->MakeExternal(resource));
1042 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1043 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString());
1044
1045 CHECK_EQ("\"bcdefghijklmnopqrstuvwxyz\"",
1046 *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)")));
1047 }
1048
1049
1020 TEST(CachedHashOverflow) { 1050 TEST(CachedHashOverflow) {
1021 // We incorrectly allowed strings to be tagged as array indices even if their 1051 // We incorrectly allowed strings to be tagged as array indices even if their
1022 // values didn't fit in the hash field. 1052 // values didn't fit in the hash field.
1023 // See http://code.google.com/p/v8/issues/detail?id=728 1053 // See http://code.google.com/p/v8/issues/detail?id=728
1024 Isolate* isolate = Isolate::Current(); 1054 Isolate* isolate = Isolate::Current();
1025 Zone zone(isolate); 1055 Zone zone(isolate);
1026 1056
1027 CcTest::InitializeVM(); 1057 CcTest::InitializeVM();
1028 v8::HandleScope handle_scope(CcTest::isolate()); 1058 v8::HandleScope handle_scope(CcTest::isolate());
1029 // Lines must be executed sequentially. Combining them into one script 1059 // Lines must be executed sequentially. Combining them into one script
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 CheckCanonicalEquivalence(c, test); 1379 CheckCanonicalEquivalence(c, test);
1350 continue; 1380 continue;
1351 } 1381 }
1352 if (upper != c && lower != c) { 1382 if (upper != c && lower != c) {
1353 CheckCanonicalEquivalence(c, test); 1383 CheckCanonicalEquivalence(c, test);
1354 continue; 1384 continue;
1355 } 1385 }
1356 CHECK_EQ(Min(upper, lower), test); 1386 CHECK_EQ(Min(upper, lower), test);
1357 } 1387 }
1358 } 1388 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/allocation-folding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698