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

Side by Side Diff: runtime/vm/object_test.cc

Issue 442483002: Avoid redundant allocation of accessor names. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | « runtime/vm/object.cc ('k') | runtime/vm/symbols.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length()); 1329 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length());
1330 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 1330 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9,
1331 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1331 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1332 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1332 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1333 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); 1333 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]);
1334 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); 1334 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len));
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 1338
1339 TEST_CASE(StringHashConcat) {
1340 EXPECT_EQ(String::Handle(String::New("onebyte")).Hash(),
1341 String::HashConcat(String::Handle(String::New("one")),
1342 String::Handle(String::New("byte"))));
1343 uint16_t clef_utf16[] = { 0xD834, 0xDD1E };
1344 const String& clef = String::Handle(String::FromUTF16(clef_utf16, 2));
1345 int32_t clef_utf32[] = { 0x1D11E };
1346 EXPECT(clef.Equals(clef_utf32, 1));
1347 intptr_t hash32 = String::Hash(clef_utf32, 1);
1348 EXPECT_EQ(hash32, clef.Hash());
1349 EXPECT_EQ(hash32, String::HashConcat(
1350 String::Handle(String::FromUTF16(clef_utf16, 1)),
1351 String::Handle(String::FromUTF16(clef_utf16 + 1, 1))));
1352 }
1353
1354
1339 TEST_CASE(StringSubStringDifferentWidth) { 1355 TEST_CASE(StringSubStringDifferentWidth) {
1340 // Create 1-byte substring from a 1-byte source string. 1356 // Create 1-byte substring from a 1-byte source string.
1341 const char* onechars = 1357 const char* onechars =
1342 "\xC3\xB6\xC3\xB1\xC3\xA9"; 1358 "\xC3\xB6\xC3\xB1\xC3\xA9";
1343 1359
1344 const String& onestr = String::Handle(String::New(onechars)); 1360 const String& onestr = String::Handle(String::New(onechars));
1345 EXPECT(!onestr.IsNull()); 1361 EXPECT(!onestr.IsNull());
1346 EXPECT(onestr.IsOneByteString()); 1362 EXPECT(onestr.IsOneByteString());
1347 EXPECT(!onestr.IsTwoByteString()); 1363 EXPECT(!onestr.IsTwoByteString());
1348 1364
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 EXPECT_VALID(h_result); 4215 EXPECT_VALID(h_result);
4200 Integer& result = Integer::Handle(); 4216 Integer& result = Integer::Handle();
4201 result ^= Api::UnwrapHandle(h_result); 4217 result ^= Api::UnwrapHandle(h_result);
4202 String& foo = String::Handle(String::New("foo")); 4218 String& foo = String::Handle(String::New("foo"));
4203 Integer& expected = Integer::Handle(); 4219 Integer& expected = Integer::Handle();
4204 expected ^= foo.HashCode(); 4220 expected ^= foo.HashCode();
4205 EXPECT(result.IsIdenticalTo(expected)); 4221 EXPECT(result.IsIdenticalTo(expected));
4206 } 4222 }
4207 4223
4208 } // namespace dart 4224 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698