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

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

Issue 11418115: Fix Unicode issues in dart2js and dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove accidental test expectation dupe Created 8 years, 1 month 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
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/assert.h" 5 #include "platform/assert.h"
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 "10000000000000000000")); 267 "10000000000000000000"));
268 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString( 268 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString(
269 "-10000000000000000000")); 269 "-10000000000000000000"));
270 EXPECT_EQ(-1, a.CompareWith(big1)); 270 EXPECT_EQ(-1, a.CompareWith(big1));
271 EXPECT_EQ(1, a.CompareWith(big2)); 271 EXPECT_EQ(1, a.CompareWith(big2));
272 EXPECT_EQ(-1, c.CompareWith(big1)); 272 EXPECT_EQ(-1, c.CompareWith(big1));
273 EXPECT_EQ(1, c.CompareWith(big2)); 273 EXPECT_EQ(1, c.CompareWith(big2));
274 } 274 }
275 275
276 276
277 TEST_CASE(StringCompareTo) {
278 const String& abcd = String::Handle(String::New("abcd"));
279 const String& abce = String::Handle(String::New("abce"));
280 EXPECT_EQ(0, abcd.CompareTo(abcd));
281 EXPECT_EQ(0, abce.CompareTo(abce));
282 EXPECT(abcd.CompareTo(abce) < 0);
283 EXPECT(abce.CompareTo(abcd) > 0);
284
285 const int kMonkeyLen = 4;
286 const uint8_t monkey_utf8[kMonkeyLen] = { 0xf0, 0x9f, 0x90, 0xb5 };
287 const String& monkey_face =
288 String::Handle(String::New(monkey_utf8, kMonkeyLen));
289 const int kDogLen = 4;
290 // 0x1f436 DOG FACE.
291 const uint8_t dog_utf8[kDogLen] = { 0xf0, 0x9f, 0x90, 0xb6 };
292 const String& dog_face = String::Handle(String::New(dog_utf8, kDogLen));
293 EXPECT_EQ(0, monkey_face.CompareTo(monkey_face));
294 EXPECT_EQ(0, dog_face.CompareTo(dog_face));
295 EXPECT(monkey_face.CompareTo(dog_face) < 0);
296 EXPECT(dog_face.CompareTo(monkey_face) > 0);
297
298 const int kDominoLen = 4;
299 // 0x1f036 DOMINO TILE HORIZONTAL-00-05.
300 const uint8_t domino_utf8[kDominoLen] = { 0xf0, 0x9f, 0x80, 0xb6 };
301 const String& domino = String::Handle(String::New(domino_utf8, kDominoLen));
302 EXPECT_EQ(0, domino.CompareTo(domino));
303 EXPECT(domino.CompareTo(dog_face) < 0);
304 EXPECT(domino.CompareTo(monkey_face) < 0);
305 EXPECT(dog_face.CompareTo(domino) > 0);
306 EXPECT(monkey_face.CompareTo(domino) > 0);
307
308 EXPECT(abcd.CompareTo(monkey_face) < 0);
309 EXPECT(abce.CompareTo(monkey_face) < 0);
310 EXPECT(abcd.CompareTo(domino) < 0);
311 EXPECT(abce.CompareTo(domino) < 0);
312 EXPECT(domino.CompareTo(abcd) > 0);
313 EXPECT(domino.CompareTo(abcd) > 0);
314 EXPECT(monkey_face.CompareTo(abce) > 0);
315 EXPECT(monkey_face.CompareTo(abce) > 0);
316 }
317
318
277 TEST_CASE(Mint) { 319 TEST_CASE(Mint) {
278 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot 320 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot
279 // be allocated if it does fit into a Smi. 321 // be allocated if it does fit into a Smi.
280 #if !defined(ARCH_IS_64_BIT) 322 #if !defined(ARCH_IS_64_BIT)
281 { Mint& med = Mint::Handle(); 323 { Mint& med = Mint::Handle();
282 EXPECT(med.IsNull()); 324 EXPECT(med.IsNull());
283 int64_t v = DART_2PART_UINT64_C(1, 0); 325 int64_t v = DART_2PART_UINT64_C(1, 0);
284 med = Mint::New(v); 326 med = Mint::New(v);
285 EXPECT_EQ(v, med.value()); 327 EXPECT_EQ(v, med.value());
286 const String& smi_str = String::Handle(String::New("1")); 328 const String& smi_str = String::Handle(String::New("1"));
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_EQ(nine.raw(), Symbols::New("Neun")); 1569 EXPECT_EQ(nine.raw(), Symbols::New("Neun"));
1528 EXPECT_EQ(ten.raw(), Symbols::New("Zehn")); 1570 EXPECT_EQ(ten.raw(), Symbols::New("Zehn"));
1529 1571
1530 // Symbols from Strings. 1572 // Symbols from Strings.
1531 eins = String::New("Eins"); 1573 eins = String::New("Eins");
1532 EXPECT(!eins.IsSymbol()); 1574 EXPECT(!eins.IsSymbol());
1533 String& ein_symbol = String::Handle(Symbols::New(eins)); 1575 String& ein_symbol = String::Handle(Symbols::New(eins));
1534 EXPECT_EQ(one.raw(), ein_symbol.raw()); 1576 EXPECT_EQ(one.raw(), ein_symbol.raw());
1535 EXPECT(one.raw() != eins.raw()); 1577 EXPECT(one.raw() != eins.raw());
1536 1578
1579 uint16_t char16[] = { 'E', 'l', 'f' };
1580 String& elf1 = String::Handle(Symbols::New(char16, 3));
1537 int32_t char32[] = { 'E', 'l', 'f' }; 1581 int32_t char32[] = { 'E', 'l', 'f' };
1538 String& elf = String::Handle(Symbols::New(char32, 3)); 1582 String& elf2 = String::Handle(Symbols::New(char32, 3));
1539 EXPECT(elf.IsSymbol()); 1583 EXPECT(elf1.IsSymbol());
1540 EXPECT_EQ(elf.raw(), Symbols::New("Elf")); 1584 EXPECT(elf2.IsSymbol());
1585 EXPECT_EQ(elf1.raw(), Symbols::New("Elf"));
1586 EXPECT_EQ(elf2.raw(), Symbols::New("Elf"));
1541 } 1587 }
1542 1588
1543 1589
1590 TEST_CASE(SymbolUnicode) {
1591 uint16_t monkey_utf16[] = { 0xd83d, 0xdc35 }; // Unicode Monkey Face.
1592 String& monkey = String::Handle(Symbols::New(monkey_utf16, 2));
1593 EXPECT(monkey.IsSymbol());
1594 EXPECT_EQ(monkey.raw(), Symbols::New("🐵"));
cshapiro 2012/11/21 18:13:23 Please do not put non-ASCII characters in the VM s
erikcorry 2012/11/22 12:42:15 Done.
1595
1596 int32_t kMonkeyFace = 0x1f435;
1597 String& monkey2 = String::Handle(Symbols::FromCharCode(kMonkeyFace));
1598 EXPECT_EQ(monkey.raw(), monkey2.raw());
1599
1600 // Unicode cat face with tears of joy.
1601 int32_t kCatFaceWithTearsOfJoy = 0x1f639;
1602 String& cat = String::Handle(Symbols::FromCharCode(kCatFaceWithTearsOfJoy));
1603
1604 uint16_t cat_utf16[] = { 0xd83d, 0xde39 };
1605 String& cat2 = String::Handle(Symbols::New(cat_utf16, 2));
1606 EXPECT(cat2.IsSymbol());
1607 EXPECT_EQ(cat2.raw(), cat.raw());
1608 }
1609
1610
1544 TEST_CASE(Bool) { 1611 TEST_CASE(Bool) {
1545 const Bool& true_value = Bool::Handle(Bool::True()); 1612 const Bool& true_value = Bool::Handle(Bool::True());
1546 EXPECT(true_value.value()); 1613 EXPECT(true_value.value());
1547 const Bool& false_value = Bool::Handle(Bool::False()); 1614 const Bool& false_value = Bool::Handle(Bool::False());
1548 EXPECT(!false_value.value()); 1615 EXPECT(!false_value.value());
1549 } 1616 }
1550 1617
1551 1618
1552 TEST_CASE(Array) { 1619 TEST_CASE(Array) {
1553 const int kArrayLen = 5; 1620 const int kArrayLen = 5;
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); 3244 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint());
3178 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); 3245 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint());
3179 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); 3246 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint());
3180 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); 3247 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint());
3181 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); 3248 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint());
3182 } 3249 }
3183 3250
3184 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3251 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3185 3252
3186 } // namespace dart 3253 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698