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

Side by Side Diff: vm/object_test.cc

Issue 11275008: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: 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/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 463
464 464
465 TEST_CASE(String) { 465 TEST_CASE(String) {
466 const char* kHello = "Hello World!"; 466 const char* kHello = "Hello World!";
467 int32_t hello_len = strlen(kHello); 467 int32_t hello_len = strlen(kHello);
468 const String& str = String::Handle(String::New(kHello)); 468 const String& str = String::Handle(String::New(kHello));
469 EXPECT(str.IsInstance()); 469 EXPECT(str.IsInstance());
470 EXPECT(str.IsString()); 470 EXPECT(str.IsString());
471 EXPECT(str.IsOneByteString()); 471 EXPECT(str.IsOneByteString());
472 EXPECT(!str.IsTwoByteString()); 472 EXPECT(!str.IsTwoByteString());
473 EXPECT(!str.IsFourByteString());
474 EXPECT(!str.IsNumber()); 473 EXPECT(!str.IsNumber());
475 EXPECT_EQ(hello_len, str.Length()); 474 EXPECT_EQ(hello_len, str.Length());
476 EXPECT_EQ('H', str.CharAt(0)); 475 EXPECT_EQ('H', str.CharAt(0));
477 EXPECT_EQ('e', str.CharAt(1)); 476 EXPECT_EQ('e', str.CharAt(1));
478 EXPECT_EQ('l', str.CharAt(2)); 477 EXPECT_EQ('l', str.CharAt(2));
479 EXPECT_EQ('l', str.CharAt(3)); 478 EXPECT_EQ('l', str.CharAt(3));
480 EXPECT_EQ('o', str.CharAt(4)); 479 EXPECT_EQ('o', str.CharAt(4));
481 EXPECT_EQ(' ', str.CharAt(5)); 480 EXPECT_EQ(' ', str.CharAt(5));
482 EXPECT_EQ('W', str.CharAt(6)); 481 EXPECT_EQ('W', str.CharAt(6));
483 EXPECT_EQ('o', str.CharAt(7)); 482 EXPECT_EQ('o', str.CharAt(7));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 EXPECT_EQ(255, sub1.CharAt(4)); 533 EXPECT_EQ(255, sub1.CharAt(4));
535 534
536 const intptr_t kWideCharsLen = 7; 535 const intptr_t kWideCharsLen = 7;
537 uint16_t wide_chars[kWideCharsLen] = { 'H', 'e', 'l', 'l', 'o', 256, '!' }; 536 uint16_t wide_chars[kWideCharsLen] = { 'H', 'e', 'l', 'l', 'o', 256, '!' };
538 const String& two_str = String::Handle(String::New(wide_chars, 537 const String& two_str = String::Handle(String::New(wide_chars,
539 kWideCharsLen)); 538 kWideCharsLen));
540 EXPECT(two_str.IsInstance()); 539 EXPECT(two_str.IsInstance());
541 EXPECT(two_str.IsString()); 540 EXPECT(two_str.IsString());
542 EXPECT(two_str.IsTwoByteString()); 541 EXPECT(two_str.IsTwoByteString());
543 EXPECT(!two_str.IsOneByteString()); 542 EXPECT(!two_str.IsOneByteString());
544 EXPECT(!two_str.IsFourByteString());
545 EXPECT_EQ(kWideCharsLen, two_str.Length()); 543 EXPECT_EQ(kWideCharsLen, two_str.Length());
546 EXPECT_EQ('H', two_str.CharAt(0)); 544 EXPECT_EQ('H', two_str.CharAt(0));
547 EXPECT_EQ(256, two_str.CharAt(5)); 545 EXPECT_EQ(256, two_str.CharAt(5));
548 const intptr_t kWideCharsIndex = 3; 546 const intptr_t kWideCharsIndex = 3;
549 const String& sub2 = String::Handle(String::SubString(two_str, kCharsIndex)); 547 const String& sub2 = String::Handle(String::SubString(two_str, kCharsIndex));
550 EXPECT_EQ((kWideCharsLen - kWideCharsIndex), sub2.Length()); 548 EXPECT_EQ((kWideCharsLen - kWideCharsIndex), sub2.Length());
551 EXPECT_EQ('l', sub2.CharAt(0)); 549 EXPECT_EQ('l', sub2.CharAt(0));
552 EXPECT_EQ('o', sub2.CharAt(1)); 550 EXPECT_EQ('o', sub2.CharAt(1));
553 EXPECT_EQ(256, sub2.CharAt(2)); 551 EXPECT_EQ(256, sub2.CharAt(2));
554 EXPECT_EQ('!', sub2.CharAt(3)); 552 EXPECT_EQ('!', sub2.CharAt(3));
555 553
556 { 554 {
557 const String& str1 = String::Handle(String::New("My.create")); 555 const String& str1 = String::Handle(String::New("My.create"));
558 const String& str2 = String::Handle(String::New("My")); 556 const String& str2 = String::Handle(String::New("My"));
559 const String& str3 = String::Handle(String::New("create")); 557 const String& str3 = String::Handle(String::New("create"));
560 EXPECT_EQ(true, str1.StartsWith(str2)); 558 EXPECT_EQ(true, str1.StartsWith(str2));
561 EXPECT_EQ(false, str1.StartsWith(str3)); 559 EXPECT_EQ(false, str1.StartsWith(str3));
562 } 560 }
563 561
564 const uint32_t four_chars[] = { 'C', 0xFF, 'h', 0xFFFF, 'a', 0x10FFFF, 'r' }; 562 const uint32_t four_chars[] = { 'C', 0xFF, 'h', 0xFFFF, 'a', 0x10FFFF, 'r' };
565 const String& four_str = String::Handle(String::New(four_chars, 7)); 563 const String& four_str = String::Handle(String::New(four_chars, 7));
566 EXPECT_EQ(four_str.Hash(), four_str.Hash()); 564 EXPECT_EQ(four_str.Hash(), four_str.Hash());
567 EXPECT(!four_str.IsTwoByteString()); 565 EXPECT(four_str.IsTwoByteString());
568 EXPECT(!four_str.IsOneByteString()); 566 EXPECT(!four_str.IsOneByteString());
569 EXPECT(four_str.IsFourByteString());
570 EXPECT_EQ(7, four_str.Length()); 567 EXPECT_EQ(7, four_str.Length());
571 EXPECT_EQ('C', four_str.CharAt(0)); 568 EXPECT_EQ('C', four_str.CharAt(0));
572 EXPECT_EQ(0xFF, four_str.CharAt(1)); 569 EXPECT_EQ(0xFF, four_str.CharAt(1));
573 EXPECT_EQ('h', four_str.CharAt(2)); 570 EXPECT_EQ('h', four_str.CharAt(2));
574 EXPECT_EQ(0xFFFF, four_str.CharAt(3)); 571 EXPECT_EQ(0xFFFF, four_str.CharAt(3));
575 EXPECT_EQ('a', four_str.CharAt(4)); 572 EXPECT_EQ('a', four_str.CharAt(4));
576 EXPECT_EQ(0x10FFFF, four_str.CharAt(5)); 573 EXPECT_EQ(0x10FFFF, four_str.CharAt(5));
577 EXPECT_EQ('r', four_str.CharAt(6)); 574 EXPECT_EQ('r', four_str.CharAt(6));
578 575
579 // Create a 1-byte string from an array of 2-byte elements. 576 // Create a 1-byte string from an array of 2-byte elements.
580 { 577 {
581 const uint16_t char16[] = { 0x00, 0x7F, 0xFF }; 578 const uint16_t char16[] = { 0x00, 0x7F, 0xFF };
582 const String& str8 = String::Handle(String::New(char16, 3)); 579 const String& str8 = String::Handle(String::New(char16, 3));
583 EXPECT(str8.IsOneByteString()); 580 EXPECT(str8.IsOneByteString());
584 EXPECT(!str8.IsTwoByteString()); 581 EXPECT(!str8.IsTwoByteString());
585 EXPECT(!str8.IsFourByteString());
586 EXPECT_EQ(0x00, str8.CharAt(0)); 582 EXPECT_EQ(0x00, str8.CharAt(0));
587 EXPECT_EQ(0x7F, str8.CharAt(1)); 583 EXPECT_EQ(0x7F, str8.CharAt(1));
588 EXPECT_EQ(0xFF, str8.CharAt(2)); 584 EXPECT_EQ(0xFF, str8.CharAt(2));
589 } 585 }
590 586
591 // Create a 1-byte string from an array of 4-byte elements. 587 // Create a 1-byte string from an array of 4-byte elements.
592 { 588 {
593 const uint32_t char32[] = { 0x00, 0x7F, 0xFF }; 589 const uint32_t char32[] = { 0x00, 0x7F, 0xFF };
594 const String& str8 = String::Handle(String::New(char32, 3)); 590 const String& str8 = String::Handle(String::New(char32, 3));
595 EXPECT(str8.IsOneByteString()); 591 EXPECT(str8.IsOneByteString());
596 EXPECT(!str8.IsTwoByteString()); 592 EXPECT(!str8.IsTwoByteString());
597 EXPECT(!str8.IsFourByteString());
598 EXPECT_EQ(0x00, str8.CharAt(0)); 593 EXPECT_EQ(0x00, str8.CharAt(0));
599 EXPECT_EQ(0x7F, str8.CharAt(1)); 594 EXPECT_EQ(0x7F, str8.CharAt(1));
600 EXPECT_EQ(0xFF, str8.CharAt(2)); 595 EXPECT_EQ(0xFF, str8.CharAt(2));
601 } 596 }
602 597
603 // Create a 2-byte string from an array of 4-byte elements. 598 // Create a 2-byte string from an array of 4-byte elements.
604 { 599 {
605 const uint32_t char32[] = { 0, 0x7FFF, 0xFFFF }; 600 const uint32_t char32[] = { 0, 0x7FFF, 0xFFFF };
606 const String& str16 = String::Handle(String::New(char32, 3)); 601 const String& str16 = String::Handle(String::New(char32, 3));
607 EXPECT(!str16.IsOneByteString()); 602 EXPECT(!str16.IsOneByteString());
608 EXPECT(str16.IsTwoByteString()); 603 EXPECT(str16.IsTwoByteString());
609 EXPECT(!str16.IsFourByteString());
610 EXPECT_EQ(0x0000, str16.CharAt(0)); 604 EXPECT_EQ(0x0000, str16.CharAt(0));
611 EXPECT_EQ(0x7FFF, str16.CharAt(1)); 605 EXPECT_EQ(0x7FFF, str16.CharAt(1));
612 EXPECT_EQ(0xFFFF, str16.CharAt(2)); 606 EXPECT_EQ(0xFFFF, str16.CharAt(2));
613 } 607 }
614 } 608 }
615 609
616 610
617 TEST_CASE(StringFormat) { 611 TEST_CASE(StringFormat) {
618 const char* hello_str = "Hello World!"; 612 const char* hello_str = "Hello World!";
619 const String& str = 613 const String& str =
620 String::Handle(String::NewFormatted("Hello %s!", "World")); 614 String::Handle(String::NewFormatted("Hello %s!", "World"));
621 EXPECT(str.IsInstance()); 615 EXPECT(str.IsInstance());
622 EXPECT(str.IsString()); 616 EXPECT(str.IsString());
623 EXPECT(str.IsOneByteString()); 617 EXPECT(str.IsOneByteString());
624 EXPECT(!str.IsTwoByteString()); 618 EXPECT(!str.IsTwoByteString());
625 EXPECT(!str.IsFourByteString());
626 EXPECT(!str.IsNumber()); 619 EXPECT(!str.IsNumber());
627 EXPECT(str.Equals(hello_str)); 620 EXPECT(str.Equals(hello_str));
628 } 621 }
629 622
630 623
631 TEST_CASE(StringConcat) { 624 TEST_CASE(StringConcat) {
632 // Create strings from concatenated 1-byte empty strings. 625 // Create strings from concatenated 1-byte empty strings.
633 { 626 {
634 const String& empty1 = String::Handle(String::New("")); 627 const String& empty1 = String::Handle(String::New(""));
635 EXPECT(empty1.IsOneByteString()); 628 EXPECT(empty1.IsOneByteString());
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 938
946 // Concatenated emtpy and non-empty 4-byte strings. 939 // Concatenated emtpy and non-empty 4-byte strings.
947 { 940 {
948 const String& str1 = String::Handle(String::New("")); 941 const String& str1 = String::Handle(String::New(""));
949 EXPECT(str1.IsOneByteString()); 942 EXPECT(str1.IsOneByteString());
950 EXPECT_EQ(0, str1.Length()); 943 EXPECT_EQ(0, str1.Length());
951 944
952 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 945 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
953 intptr_t four_len = sizeof(four) / sizeof(four[0]); 946 intptr_t four_len = sizeof(four) / sizeof(four[0]);
954 const String& str2 = String::Handle(String::New(four, four_len)); 947 const String& str2 = String::Handle(String::New(four, four_len));
955 EXPECT(str2.IsFourByteString()); 948 EXPECT(str2.IsTwoByteString());
956 EXPECT_EQ(4, str2.Length()); 949 EXPECT_EQ(4, str2.Length());
957 950
958 // Concat 951 // Concat
959 952
960 const String& str3 = String::Handle(String::Concat(str1, str2)); 953 const String& str3 = String::Handle(String::Concat(str1, str2));
961 EXPECT_EQ(four_len, str3.Length()); 954 EXPECT_EQ(four_len, str3.Length());
962 EXPECT(str3.Equals(str2)); 955 EXPECT(str3.Equals(str2));
963 956
964 const String& str4 = String::Handle(String::Concat(str2, str1)); 957 const String& str4 = String::Handle(String::Concat(str2, str1));
965 EXPECT(str4.IsFourByteString()); 958 EXPECT(str4.IsTwoByteString());
966 EXPECT_EQ(four_len, str4.Length()); 959 EXPECT_EQ(four_len, str4.Length());
967 EXPECT(str4.Equals(str2)); 960 EXPECT(str4.Equals(str2));
968 961
969 // ConcatAll 962 // ConcatAll
970 963
971 const Array& array1 = Array::Handle(Array::New(2)); 964 const Array& array1 = Array::Handle(Array::New(2));
972 EXPECT_EQ(2, array1.Length()); 965 EXPECT_EQ(2, array1.Length());
973 array1.SetAt(0, str1); 966 array1.SetAt(0, str1);
974 array1.SetAt(1, str2); 967 array1.SetAt(1, str2);
975 const String& str5 = String::Handle(String::ConcatAll(array1)); 968 const String& str5 = String::Handle(String::ConcatAll(array1));
976 EXPECT(str5.IsFourByteString()); 969 EXPECT(str5.IsTwoByteString());
977 EXPECT_EQ(four_len, str5.Length()); 970 EXPECT_EQ(four_len, str5.Length());
978 EXPECT(str5.Equals(str2)); 971 EXPECT(str5.Equals(str2));
979 972
980 const Array& array2 = Array::Handle(Array::New(2)); 973 const Array& array2 = Array::Handle(Array::New(2));
981 EXPECT_EQ(2, array2.Length()); 974 EXPECT_EQ(2, array2.Length());
982 array2.SetAt(0, str1); 975 array2.SetAt(0, str1);
983 array2.SetAt(1, str2); 976 array2.SetAt(1, str2);
984 const String& str6 = String::Handle(String::ConcatAll(array2)); 977 const String& str6 = String::Handle(String::ConcatAll(array2));
985 EXPECT(str6.IsFourByteString()); 978 EXPECT(str6.IsTwoByteString());
986 EXPECT_EQ(four_len, str6.Length()); 979 EXPECT_EQ(four_len, str6.Length());
987 EXPECT(str6.Equals(str2)); 980 EXPECT(str6.Equals(str2));
988 981
989 const Array& array3 = Array::Handle(Array::New(3)); 982 const Array& array3 = Array::Handle(Array::New(3));
990 EXPECT_EQ(3, array3.Length()); 983 EXPECT_EQ(3, array3.Length());
991 array3.SetAt(0, str2); 984 array3.SetAt(0, str2);
992 array3.SetAt(1, str1); 985 array3.SetAt(1, str1);
993 array3.SetAt(2, str2); 986 array3.SetAt(2, str2);
994 const String& str7 = String::Handle(String::ConcatAll(array3)); 987 const String& str7 = String::Handle(String::ConcatAll(array3));
995 EXPECT(str7.IsFourByteString()); 988 EXPECT(str7.IsTwoByteString());
996 uint32_t fourfour[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1, 989 uint32_t fourfour[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1,
997 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 990 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
998 intptr_t fourfour_len = sizeof(fourfour) / sizeof(fourfour[0]); 991 intptr_t fourfour_len = sizeof(fourfour) / sizeof(fourfour[0]);
999 EXPECT_EQ(fourfour_len, str7.Length()); 992 EXPECT_EQ(fourfour_len, str7.Length());
1000 EXPECT(str7.Equals(fourfour, fourfour_len)); 993 EXPECT(str7.Equals(fourfour, fourfour_len));
1001 } 994 }
1002 995
1003 // Concatenate non-empty 4-byte strings. 996 // Concatenate non-empty 4-byte strings.
1004 { 997 {
1005 const uint32_t one[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF }; 998 const uint32_t one[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF };
1006 intptr_t one_len = sizeof(one) / sizeof(one[0]); 999 intptr_t one_len = sizeof(one) / sizeof(one[0]);
1007 const String& onestr = String::Handle(String::New(one, one_len)); 1000 const String& onestr = String::Handle(String::New(one, one_len));
1008 EXPECT(onestr.IsFourByteString()); 1001 EXPECT(onestr.IsTwoByteString());
1009 EXPECT_EQ(one_len, onestr.Length()); 1002 EXPECT_EQ(one_len, onestr.Length());
1010 1003
1011 const uint32_t two[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9 }; 1004 const uint32_t two[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9 };
1012 intptr_t two_len = sizeof(two) / sizeof(two[0]); 1005 intptr_t two_len = sizeof(two) / sizeof(two[0]);
1013 const String& twostr = String::Handle(String::New(two, two_len)); 1006 const String& twostr = String::Handle(String::New(two, two_len));
1014 EXPECT(twostr.IsFourByteString()); 1007 EXPECT(twostr.IsTwoByteString());
1015 EXPECT_EQ(two_len, twostr.Length()); 1008 EXPECT_EQ(two_len, twostr.Length());
1016 1009
1017 // Concat 1010 // Concat
1018 1011
1019 const String& str1 = String::Handle(String::Concat(onestr, twostr)); 1012 const String& str1 = String::Handle(String::Concat(onestr, twostr));
1020 EXPECT(str1.IsFourByteString()); 1013 EXPECT(str1.IsTwoByteString());
1021 const uint32_t one_two[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF, 1014 const uint32_t one_two[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF,
1022 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9 }; 1015 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9 };
1023 intptr_t one_two_len = sizeof(one_two) / sizeof(one_two[0]); 1016 intptr_t one_two_len = sizeof(one_two) / sizeof(one_two[0]);
1024 EXPECT_EQ(one_two_len, str1.Length()); 1017 EXPECT_EQ(one_two_len, str1.Length());
1025 EXPECT(str1.Equals(one_two, one_two_len)); 1018 EXPECT(str1.Equals(one_two, one_two_len));
1026 1019
1027 const String& str2 = String::Handle(String::Concat(twostr, onestr)); 1020 const String& str2 = String::Handle(String::Concat(twostr, onestr));
1028 EXPECT(str2.IsFourByteString()); 1021 EXPECT(str2.IsTwoByteString());
1029 const uint32_t two_one[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9, 1022 const uint32_t two_one[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9, 0x105D9,
1030 0x105D0, 0x105D9, 0x105D9, 0x105DF }; 1023 0x105D0, 0x105D9, 0x105D9, 0x105DF };
1031 intptr_t two_one_len = sizeof(two_one) / sizeof(two_one[0]); 1024 intptr_t two_one_len = sizeof(two_one) / sizeof(two_one[0]);
1032 EXPECT_EQ(two_one_len, str2.Length()); 1025 EXPECT_EQ(two_one_len, str2.Length());
1033 EXPECT(str2.Equals(two_one, two_one_len)); 1026 EXPECT(str2.Equals(two_one, two_one_len));
1034 1027
1035 // ConcatAll 1028 // ConcatAll
1036 1029
1037 const Array& array1 = Array::Handle(Array::New(2)); 1030 const Array& array1 = Array::Handle(Array::New(2));
1038 EXPECT_EQ(2, array1.Length()); 1031 EXPECT_EQ(2, array1.Length());
1039 array1.SetAt(0, onestr); 1032 array1.SetAt(0, onestr);
1040 array1.SetAt(1, twostr); 1033 array1.SetAt(1, twostr);
1041 const String& str3 = String::Handle(String::ConcatAll(array1)); 1034 const String& str3 = String::Handle(String::ConcatAll(array1));
1042 EXPECT(str3.IsFourByteString()); 1035 EXPECT(str3.IsTwoByteString());
1043 EXPECT_EQ(one_two_len, str3.Length()); 1036 EXPECT_EQ(one_two_len, str3.Length());
1044 EXPECT(str3.Equals(one_two, one_two_len)); 1037 EXPECT(str3.Equals(one_two, one_two_len));
1045 1038
1046 const Array& array2 = Array::Handle(Array::New(2)); 1039 const Array& array2 = Array::Handle(Array::New(2));
1047 EXPECT_EQ(2, array2.Length()); 1040 EXPECT_EQ(2, array2.Length());
1048 array2.SetAt(0, twostr); 1041 array2.SetAt(0, twostr);
1049 array2.SetAt(1, onestr); 1042 array2.SetAt(1, onestr);
1050 const String& str4 = String::Handle(String::ConcatAll(array2)); 1043 const String& str4 = String::Handle(String::ConcatAll(array2));
1051 EXPECT(str4.IsFourByteString()); 1044 EXPECT(str4.IsTwoByteString());
1052 EXPECT_EQ(two_one_len, str4.Length()); 1045 EXPECT_EQ(two_one_len, str4.Length());
1053 EXPECT(str4.Equals(two_one, two_one_len)); 1046 EXPECT(str4.Equals(two_one, two_one_len));
1054 1047
1055 const Array& array3 = Array::Handle(Array::New(3)); 1048 const Array& array3 = Array::Handle(Array::New(3));
1056 EXPECT_EQ(3, array3.Length()); 1049 EXPECT_EQ(3, array3.Length());
1057 array3.SetAt(0, onestr); 1050 array3.SetAt(0, onestr);
1058 array3.SetAt(1, twostr); 1051 array3.SetAt(1, twostr);
1059 array3.SetAt(2, onestr); 1052 array3.SetAt(2, onestr);
1060 const String& str5 = String::Handle(String::ConcatAll(array3)); 1053 const String& str5 = String::Handle(String::ConcatAll(array3));
1061 EXPECT(str5.IsFourByteString()); 1054 EXPECT(str5.IsTwoByteString());
1062 const uint32_t one_two_one[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF, 1055 const uint32_t one_two_one[] = { 0x105D0, 0x105D9, 0x105D9, 0x105DF,
1063 0x105E6, 0x105D5, 0x105D5, 0x105D9, 1056 0x105E6, 0x105D5, 0x105D5, 0x105D9,
1064 0x105D9, 1057 0x105D9,
1065 0x105D0, 0x105D9, 0x105D9, 0x105DF }; 1058 0x105D0, 0x105D9, 0x105D9, 0x105DF };
1066 intptr_t one_two_one_len = sizeof(one_two_one) / sizeof(one_two_one[0]); 1059 intptr_t one_two_one_len = sizeof(one_two_one) / sizeof(one_two_one[0]);
1067 EXPECT_EQ(one_two_one_len, str5.Length()); 1060 EXPECT_EQ(one_two_one_len, str5.Length());
1068 EXPECT(str5.Equals(one_two_one, one_two_one_len)); 1061 EXPECT(str5.Equals(one_two_one, one_two_one_len));
1069 1062
1070 const Array& array4 = Array::Handle(Array::New(3)); 1063 const Array& array4 = Array::Handle(Array::New(3));
1071 EXPECT_EQ(3, array4.Length()); 1064 EXPECT_EQ(3, array4.Length());
1072 array4.SetAt(0, twostr); 1065 array4.SetAt(0, twostr);
1073 array4.SetAt(1, onestr); 1066 array4.SetAt(1, onestr);
1074 array4.SetAt(2, twostr); 1067 array4.SetAt(2, twostr);
1075 const String& str6 = String::Handle(String::ConcatAll(array4)); 1068 const String& str6 = String::Handle(String::ConcatAll(array4));
1076 EXPECT(str6.IsFourByteString()); 1069 EXPECT(str6.IsTwoByteString());
1077 const uint32_t two_one_two[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9, 1070 const uint32_t two_one_two[] = { 0x105E6, 0x105D5, 0x105D5, 0x105D9,
1078 0x105D9, 1071 0x105D9,
1079 0x105D0, 0x105D9, 0x105D9, 0x105DF, 1072 0x105D0, 0x105D9, 0x105D9, 0x105DF,
1080 0x105E6, 0x105D5, 0x105D5, 0x105D9, 1073 0x105E6, 0x105D5, 0x105D5, 0x105D9,
1081 0x105D9 }; 1074 0x105D9 };
1082 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); 1075 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]);
1083 EXPECT_EQ(two_one_two_len, str6.Length()); 1076 EXPECT_EQ(two_one_two_len, str6.Length());
1084 EXPECT(str6.Equals(two_one_two, two_one_two_len)); 1077 EXPECT(str6.Equals(two_one_two, two_one_two_len));
1085 } 1078 }
1086 1079
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 const String& two_one_two_str = String::Handle(String::ConcatAll(array2)); 1135 const String& two_one_two_str = String::Handle(String::ConcatAll(array2));
1143 EXPECT(two_one_two_str.IsTwoByteString()); 1136 EXPECT(two_one_two_str.IsTwoByteString());
1144 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length()); 1137 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length());
1145 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 1138 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9,
1146 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1139 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1147 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1140 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1148 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); 1141 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]);
1149 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); 1142 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len));
1150 } 1143 }
1151 1144
1152 // Concatenate 1-byte strings and 4-byte strings. 1145 // Concatenate 1byte strings and 4byte strings.
1153 { 1146 {
1154 const uint8_t one[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' }; 1147 const uint8_t one[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' };
1155 intptr_t one_len = sizeof(one) / sizeof(one[0]); 1148 intptr_t one_len = sizeof(one) / sizeof(one[0]);
1156 const String& onestr = String::Handle(String::New(one, one_len)); 1149 const String& onestr = String::Handle(String::New(one, one_len));
1157 EXPECT(onestr.IsOneByteString()); 1150 EXPECT(onestr.IsOneByteString());
1158 EXPECT_EQ(one_len, onestr.Length()); 1151 EXPECT_EQ(one_len, onestr.Length());
1159 EXPECT(onestr.Equals(one, one_len)); 1152 EXPECT(onestr.Equals(one, one_len));
1160 1153
1161 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1154 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1162 intptr_t four_len = sizeof(four) / sizeof(four[0]); 1155 intptr_t four_len = sizeof(four) / sizeof(four[0]);
1163 const String& fourstr = String::Handle(String::New(four, four_len)); 1156 const String& fourstr = String::Handle(String::New(four, four_len));
1164 EXPECT(fourstr.IsFourByteString()); 1157 EXPECT(fourstr.IsTwoByteString());
1165 EXPECT_EQ(four_len, fourstr.Length()); 1158 EXPECT_EQ(four_len, fourstr.Length());
1166 EXPECT(fourstr.Equals(four, four_len)); 1159 EXPECT(fourstr.Equals(four, four_len));
1167 1160
1168 // Concat 1161 // Concat
1169 1162
1170 const String& one_four_str = String::Handle(String::Concat(onestr, 1163 const String& one_four_str = String::Handle(String::Concat(onestr,
1171 fourstr)); 1164 fourstr));
1172 EXPECT(one_four_str.IsFourByteString()); 1165 EXPECT(one_four_str.IsTwoByteString());
1173 uint32_t one_four[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1166 uint32_t one_four[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1174 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1167 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1175 intptr_t one_four_len = sizeof(one_four) / sizeof(one_four[0]); 1168 intptr_t one_four_len = sizeof(one_four) / sizeof(one_four[0]);
1176 EXPECT_EQ(one_four_len, one_four_str.Length()); 1169 EXPECT_EQ(one_four_len, one_four_str.Length());
1177 EXPECT(one_four_str.Equals(one_four, one_four_len)); 1170 EXPECT(one_four_str.Equals(one_four, one_four_len));
1178 1171
1179 const String& four_one_str = String::Handle(String::Concat(fourstr, 1172 const String& four_one_str = String::Handle(String::Concat(fourstr,
1180 onestr)); 1173 onestr));
1181 EXPECT(four_one_str.IsFourByteString()); 1174 EXPECT(four_one_str.IsTwoByteString());
1182 uint32_t four_one[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1, 1175 uint32_t four_one[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1,
1183 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' }; 1176 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' };
1184 intptr_t four_one_len = sizeof(four_one) / sizeof(four_one[0]); 1177 intptr_t four_one_len = sizeof(four_one) / sizeof(four_one[0]);
1185 EXPECT_EQ(four_one_len, four_one_str.Length()); 1178 EXPECT_EQ(four_one_len, four_one_str.Length());
1186 EXPECT(four_one_str.Equals(four_one, four_one_len)); 1179 EXPECT(four_one_str.Equals(four_one, four_one_len));
1187 1180
1188 // ConcatAll 1181 // ConcatAll
1189 1182
1190 const Array& array1 = Array::Handle(Array::New(3)); 1183 const Array& array1 = Array::Handle(Array::New(3));
1191 EXPECT_EQ(3, array1.Length()); 1184 EXPECT_EQ(3, array1.Length());
1192 array1.SetAt(0, onestr); 1185 array1.SetAt(0, onestr);
1193 array1.SetAt(1, fourstr); 1186 array1.SetAt(1, fourstr);
1194 array1.SetAt(2, onestr); 1187 array1.SetAt(2, onestr);
1195 const String& one_four_one = String::Handle(String::ConcatAll(array1)); 1188 const String& one_four_one = String::Handle(String::ConcatAll(array1));
1196 EXPECT(one_four_one.IsFourByteString()); 1189 EXPECT(one_four_one.IsTwoByteString());
1197 EXPECT_EQ(onestr.Length()*2 + fourstr.Length(), one_four_one.Length()); 1190 EXPECT_EQ(onestr.Length()*2 + fourstr.Length(), one_four_one.Length());
1198 1191
1199 const Array& array2 = Array::Handle(Array::New(3)); 1192 const Array& array2 = Array::Handle(Array::New(3));
1200 EXPECT_EQ(3, array2.Length()); 1193 EXPECT_EQ(3, array2.Length());
1201 array2.SetAt(0, fourstr); 1194 array2.SetAt(0, fourstr);
1202 array2.SetAt(1, onestr); 1195 array2.SetAt(1, onestr);
1203 array2.SetAt(2, fourstr); 1196 array2.SetAt(2, fourstr);
1204 const String& four_one_four = String::Handle(String::ConcatAll(array2)); 1197 const String& four_one_four = String::Handle(String::ConcatAll(array2));
1205 EXPECT(four_one_four.IsFourByteString()); 1198 EXPECT(four_one_four.IsTwoByteString());
1206 EXPECT_EQ(fourstr.Length()*2 + onestr.Length(), four_one_four.Length()); 1199 EXPECT_EQ(fourstr.Length()*2 + onestr.Length(), four_one_four.Length());
1207 } 1200 }
1208 1201
1209 // Concatenate 2-byte strings and 4-byte strings. 1202 // Concatenate 2byte strings and 4byte strings.
1210 { 1203 {
1211 uint16_t two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1204 uint16_t two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1212 intptr_t two_len = sizeof(two) / sizeof(two[0]); 1205 intptr_t two_len = sizeof(two) / sizeof(two[0]);
1213 const String& twostr = String::Handle(String::New(two, two_len)); 1206 const String& twostr = String::Handle(String::New(two, two_len));
1214 EXPECT(twostr.IsTwoByteString()); 1207 EXPECT(twostr.IsTwoByteString());
1215 EXPECT_EQ(two_len, twostr.Length()); 1208 EXPECT_EQ(two_len, twostr.Length());
1216 EXPECT(twostr.Equals(two, two_len)); 1209 EXPECT(twostr.Equals(two, two_len));
1217 1210
1218 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1211 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1219 intptr_t four_len = sizeof(four) / sizeof(four[0]); 1212 intptr_t four_len = sizeof(four) / sizeof(four[0]);
1220 const String& fourstr = String::Handle(String::New(four, four_len)); 1213 const String& fourstr = String::Handle(String::New(four, four_len));
1221 EXPECT(fourstr.IsFourByteString()); 1214 EXPECT(fourstr.IsTwoByteString());
1222 EXPECT_EQ(four_len, fourstr.Length()); 1215 EXPECT_EQ(four_len, fourstr.Length());
1223 EXPECT(fourstr.Equals(four, four_len)); 1216 EXPECT(fourstr.Equals(four, four_len));
1224 1217
1225 // Concat 1218 // Concat
1226 1219
1227 const String& two_four_str = String::Handle(String::Concat(twostr, 1220 const String& two_four_str = String::Handle(String::Concat(twostr,
1228 fourstr)); 1221 fourstr));
1229 EXPECT(two_four_str.IsFourByteString()); 1222 EXPECT(two_four_str.IsTwoByteString());
1230 uint32_t two_four[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 1223 uint32_t two_four[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9,
1231 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1224 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1232 intptr_t two_four_len = sizeof(two_four) / sizeof(two_four[0]); 1225 intptr_t two_four_len = sizeof(two_four) / sizeof(two_four[0]);
1233 EXPECT_EQ(two_four_len, two_four_str.Length()); 1226 EXPECT_EQ(two_four_len, two_four_str.Length());
1234 EXPECT(two_four_str.Equals(two_four, two_four_len)); 1227 EXPECT(two_four_str.Equals(two_four, two_four_len));
1235 1228
1236 const String& four_two_str = String::Handle(String::Concat(fourstr, 1229 const String& four_two_str = String::Handle(String::Concat(fourstr,
1237 twostr)); 1230 twostr));
1238 EXPECT(four_two_str.IsFourByteString()); 1231 EXPECT(four_two_str.IsTwoByteString());
1239 uint32_t four_two[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1, 1232 uint32_t four_two[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1,
1240 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1233 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1241 intptr_t four_two_len = sizeof(four_two) / sizeof(four_two[0]); 1234 intptr_t four_two_len = sizeof(four_two) / sizeof(four_two[0]);
1242 EXPECT_EQ(four_two_len, four_two_str.Length()); 1235 EXPECT_EQ(four_two_len, four_two_str.Length());
1243 EXPECT(four_two_str.Equals(four_two, four_two_len)); 1236 EXPECT(four_two_str.Equals(four_two, four_two_len));
1244 1237
1245 // ConcatAll 1238 // ConcatAll
1246 1239
1247 const Array& array1 = Array::Handle(Array::New(3)); 1240 const Array& array1 = Array::Handle(Array::New(3));
1248 EXPECT_EQ(3, array1.Length()); 1241 EXPECT_EQ(3, array1.Length());
1249 array1.SetAt(0, twostr); 1242 array1.SetAt(0, twostr);
1250 array1.SetAt(1, fourstr); 1243 array1.SetAt(1, fourstr);
1251 array1.SetAt(2, twostr); 1244 array1.SetAt(2, twostr);
1252 const String& two_four_two_str = String::Handle(String::ConcatAll(array1)); 1245 const String& two_four_two_str = String::Handle(String::ConcatAll(array1));
1253 EXPECT(two_four_two_str.IsFourByteString()); 1246 EXPECT(two_four_two_str.IsTwoByteString());
1254 EXPECT_EQ(twostr.Length()*2 + fourstr.Length(), two_four_two_str.Length()); 1247 EXPECT_EQ(twostr.Length()*2 + fourstr.Length(), two_four_two_str.Length());
1255 1248
1256 const Array& array2 = Array::Handle(Array::New(3)); 1249 const Array& array2 = Array::Handle(Array::New(3));
1257 EXPECT_EQ(3, array2.Length()); 1250 EXPECT_EQ(3, array2.Length());
1258 array2.SetAt(0, fourstr); 1251 array2.SetAt(0, fourstr);
1259 array2.SetAt(1, twostr); 1252 array2.SetAt(1, twostr);
1260 array2.SetAt(2, fourstr); 1253 array2.SetAt(2, fourstr);
1261 const String& four_two_four_str = String::Handle(String::ConcatAll(array2)); 1254 const String& four_two_four_str = String::Handle(String::ConcatAll(array2));
1262 EXPECT(four_two_four_str.IsFourByteString()); 1255 EXPECT(four_two_four_str.IsTwoByteString());
1263 EXPECT_EQ(fourstr.Length()*2 + twostr.Length(), four_two_four_str.Length()); 1256 EXPECT_EQ(fourstr.Length()*2 + twostr.Length(), four_two_four_str.Length());
1264 } 1257 }
1265 1258
1266 // Concatenate 1-byte, 2-byte and 4-byte strings. 1259 // Concatenate 1byte, 2byte and 4byte strings.
cshapiro 2012/10/24 23:52:29 Not sure why this was changed. The rules of gramm
siva 2012/10/26 21:38:29 Restored to original format. On 2012/10/24 23:52:
1267 { 1260 {
1268 const uint8_t one[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' }; 1261 const uint8_t one[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e' };
1269 intptr_t one_len = sizeof(one) / sizeof(one[0]); 1262 intptr_t one_len = sizeof(one) / sizeof(one[0]);
1270 const String& onestr = String::Handle(String::New(one, one_len)); 1263 const String& onestr = String::Handle(String::New(one, one_len));
1271 EXPECT(onestr.IsOneByteString()); 1264 EXPECT(onestr.IsOneByteString());
1272 EXPECT_EQ(one_len, onestr.Length()); 1265 EXPECT_EQ(one_len, onestr.Length());
1273 EXPECT(onestr.Equals(one, one_len)); 1266 EXPECT(onestr.Equals(one, one_len));
1274 1267
1275 uint16_t two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1268 uint16_t two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1276 intptr_t two_len = sizeof(two) / sizeof(two[0]); 1269 intptr_t two_len = sizeof(two) / sizeof(two[0]);
1277 const String& twostr = String::Handle(String::New(two, two_len)); 1270 const String& twostr = String::Handle(String::New(two, two_len));
1278 EXPECT(twostr.IsTwoByteString()); 1271 EXPECT(twostr.IsTwoByteString());
1279 EXPECT_EQ(two_len, twostr.Length()); 1272 EXPECT_EQ(two_len, twostr.Length());
1280 EXPECT(twostr.Equals(two, two_len)); 1273 EXPECT(twostr.Equals(two, two_len));
1281 1274
1282 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1275 uint32_t four[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1283 intptr_t four_len = sizeof(four) / sizeof(four[0]); 1276 intptr_t four_len = sizeof(four) / sizeof(four[0]);
1284 const String& fourstr = String::Handle(String::New(four, four_len)); 1277 const String& fourstr = String::Handle(String::New(four, four_len));
1285 EXPECT(fourstr.IsFourByteString()); 1278 EXPECT(fourstr.IsTwoByteString());
1286 EXPECT_EQ(four_len, fourstr.Length()); 1279 EXPECT_EQ(four_len, fourstr.Length());
1287 EXPECT(fourstr.Equals(four, four_len)); 1280 EXPECT(fourstr.Equals(four, four_len));
1288 1281
1289 // Last element is a 4-byte string. 1282 // Last element is a 4byte string.
1290 const Array& array1 = Array::Handle(Array::New(3)); 1283 const Array& array1 = Array::Handle(Array::New(3));
1291 EXPECT_EQ(3, array1.Length()); 1284 EXPECT_EQ(3, array1.Length());
1292 array1.SetAt(0, onestr); 1285 array1.SetAt(0, onestr);
1293 array1.SetAt(1, twostr); 1286 array1.SetAt(1, twostr);
1294 array1.SetAt(2, fourstr); 1287 array1.SetAt(2, fourstr);
1295 const String& one_two_four_str = String::Handle(String::ConcatAll(array1)); 1288 const String& one_two_four_str = String::Handle(String::ConcatAll(array1));
1296 EXPECT(one_two_four_str.IsFourByteString()); 1289 EXPECT(one_two_four_str.IsTwoByteString());
1297 EXPECT_EQ(onestr.Length() + twostr.Length() + fourstr.Length(), 1290 EXPECT_EQ(onestr.Length() + twostr.Length() + fourstr.Length(),
1298 one_two_four_str.Length()); 1291 one_two_four_str.Length());
1299 uint32_t one_two_four[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1292 uint32_t one_two_four[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1300 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 1293 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9,
1301 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 }; 1294 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1 };
1302 intptr_t one_two_four_len = sizeof(one_two_four) / sizeof(one_two_four[0]); 1295 intptr_t one_two_four_len = sizeof(one_two_four) / sizeof(one_two_four[0]);
1303 EXPECT(one_two_four_str.Equals(one_two_four, one_two_four_len)); 1296 EXPECT(one_two_four_str.Equals(one_two_four, one_two_four_len));
1304 1297
1305 // Middle element is a 4-byte string. 1298 // Middle element is a 4byte string.
1306 const Array& array2 = Array::Handle(Array::New(3)); 1299 const Array& array2 = Array::Handle(Array::New(3));
1307 EXPECT_EQ(3, array2.Length()); 1300 EXPECT_EQ(3, array2.Length());
1308 array2.SetAt(0, onestr); 1301 array2.SetAt(0, onestr);
1309 array2.SetAt(1, fourstr); 1302 array2.SetAt(1, fourstr);
1310 array2.SetAt(2, twostr); 1303 array2.SetAt(2, twostr);
1311 const String& one_four_two_str = String::Handle(String::ConcatAll(array2)); 1304 const String& one_four_two_str = String::Handle(String::ConcatAll(array2));
1312 EXPECT(one_four_two_str.IsFourByteString()); 1305 EXPECT(one_four_two_str.IsTwoByteString());
1313 EXPECT_EQ(onestr.Length() + fourstr.Length() + twostr.Length(), 1306 EXPECT_EQ(onestr.Length() + fourstr.Length() + twostr.Length(),
1314 one_four_two_str.Length()); 1307 one_four_two_str.Length());
1315 uint32_t one_four_two[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1308 uint32_t one_four_two[] = { 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1316 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1, 1309 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1,
1317 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1310 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1318 intptr_t one_four_two_len = sizeof(one_four_two) / sizeof(one_four_two[0]); 1311 intptr_t one_four_two_len = sizeof(one_four_two) / sizeof(one_four_two[0]);
1319 EXPECT(one_four_two_str.Equals(one_four_two, one_four_two_len)); 1312 EXPECT(one_four_two_str.Equals(one_four_two, one_four_two_len));
1320 1313
1321 // First element is a 4-byte string. 1314 // First element is a 4byte string.
1322 const Array& array3 = Array::Handle(Array::New(3)); 1315 const Array& array3 = Array::Handle(Array::New(3));
1323 EXPECT_EQ(3, array3.Length()); 1316 EXPECT_EQ(3, array3.Length());
1324 array3.SetAt(0, fourstr); 1317 array3.SetAt(0, fourstr);
1325 array3.SetAt(1, onestr); 1318 array3.SetAt(1, onestr);
1326 array3.SetAt(2, twostr); 1319 array3.SetAt(2, twostr);
1327 const String& four_one_two_str = String::Handle(String::ConcatAll(array3)); 1320 const String& four_one_two_str = String::Handle(String::ConcatAll(array3));
1328 EXPECT(one_four_two_str.IsFourByteString()); 1321 EXPECT(one_four_two_str.IsTwoByteString());
1329 EXPECT_EQ(onestr.Length() + fourstr.Length() + twostr.Length(), 1322 EXPECT_EQ(onestr.Length() + fourstr.Length() + twostr.Length(),
1330 one_four_two_str.Length()); 1323 one_four_two_str.Length());
1331 uint32_t four_one_two[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1, 1324 uint32_t four_one_two[] = { 0x1D4D5, 0x1D4DE, 0x1D4E4, 0x1D4E1,
1332 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', 1325 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e',
1333 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; 1326 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 };
1334 intptr_t four_one_two_len = sizeof(four_one_two) / sizeof(four_one_two[0]); 1327 intptr_t four_one_two_len = sizeof(four_one_two) / sizeof(four_one_two[0]);
1335 EXPECT(four_one_two_str.Equals(four_one_two, four_one_two_len)); 1328 EXPECT(four_one_two_str.Equals(four_one_two, four_one_two_len));
1336 } 1329 }
1337 } 1330 }
1338 1331
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 EXPECT_EQ(twosub2.Length(), 3); 1364 EXPECT_EQ(twosub2.Length(), 3);
1372 1365
1373 // Create 1-, 2-, and 4-byte substrings from a 4-byte source string. 1366 // Create 1-, 2-, and 4-byte substrings from a 4-byte source string.
1374 const char* fourchars = 1367 const char* fourchars =
1375 "\xC3\xB6\xC3\xB1\xC3\xA9" 1368 "\xC3\xB6\xC3\xB1\xC3\xA9"
1376 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93" 1369 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93"
1377 "\xF0\x9D\x96\xBF\xF0\x9D\x97\x88\xF0\x9D\x97\x8E\xF0\x9D\x97\x8B"; 1370 "\xF0\x9D\x96\xBF\xF0\x9D\x97\x88\xF0\x9D\x97\x8E\xF0\x9D\x97\x8B";
1378 1371
1379 const String& fourstr = String::Handle(String::New(fourchars)); 1372 const String& fourstr = String::Handle(String::New(fourchars));
1380 EXPECT(!fourstr.IsNull()); 1373 EXPECT(!fourstr.IsNull());
1381 EXPECT(fourstr.IsFourByteString()); 1374 EXPECT(fourstr.IsTwoByteString());
1382 1375
1383 const String& foursub1 = String::Handle(String::SubString(fourstr, 0, 3)); 1376 const String& foursub1 = String::Handle(String::SubString(fourstr, 0, 3));
1384 EXPECT(!foursub1.IsNull()); 1377 EXPECT(!foursub1.IsNull());
1385 EXPECT(foursub1.IsOneByteString()); 1378 EXPECT(foursub1.IsOneByteString());
1386 EXPECT_EQ(foursub1.Length(), 3); 1379 EXPECT_EQ(foursub1.Length(), 3);
1387 1380
1388 const String& foursub2 = String::Handle(String::SubString(fourstr, 3, 3)); 1381 const String& foursub2 = String::Handle(String::SubString(fourstr, 3, 3));
1389 EXPECT(!foursub2.IsNull()); 1382 EXPECT(!foursub2.IsNull());
1390 EXPECT(foursub2.IsTwoByteString()); 1383 EXPECT(foursub2.IsTwoByteString());
1391 EXPECT_EQ(foursub2.Length(), 3); 1384 EXPECT_EQ(foursub2.Length(), 3);
1392 1385
1393 const String& foursub4 = String::Handle(String::SubString(fourstr, 6)); 1386 const String& foursub4 = String::Handle(String::SubString(fourstr, 6));
1394 EXPECT_EQ(foursub4.Length(), 4); 1387 EXPECT_EQ(foursub4.Length(), 4);
1395 EXPECT(!foursub4.IsNull()); 1388 EXPECT(!foursub4.IsNull());
1396 EXPECT(foursub4.IsFourByteString()); 1389 EXPECT(foursub4.IsTwoByteString());
1397 } 1390 }
1398 1391
1399 1392
1400 TEST_CASE(StringFromUtf8Literal) { 1393 TEST_CASE(StringFromUtf8Literal) {
1401 // Create a 1-byte string from a UTF-8 encoded string literal. 1394 // Create a 1-byte string from a UTF-8 encoded string literal.
1402 { 1395 {
1403 const char* src = 1396 const char* src =
1404 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3" 1397 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3"
1405 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7" 1398 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7"
1406 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB" 1399 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 }; 1452 };
1460 const String& str = String::Handle(String::New(src)); 1453 const String& str = String::Handle(String::New(src));
1461 EXPECT(str.IsTwoByteString()); 1454 EXPECT(str.IsTwoByteString());
1462 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); 1455 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]);
1463 EXPECT_EQ(expected_size, str.Length()); 1456 EXPECT_EQ(expected_size, str.Length());
1464 for (int i = 0; i < str.Length(); ++i) { 1457 for (int i = 0; i < str.Length(); ++i) {
1465 EXPECT_EQ(expected[i], str.CharAt(i)); 1458 EXPECT_EQ(expected[i], str.CharAt(i));
1466 } 1459 }
1467 } 1460 }
1468 1461
1469 // Create a 2-byte string from UTF-8 encoded 1- and 2-byte 1462 // Create a BMP 2-byte string from UTF-8 encoded 1- and 2-byte
1470 // characters. 1463 // characters.
1471 { 1464 {
1472 const char* src = 1465 const char* src =
1473 "\x0A\x0B\x0D\x0C\x0E\x0F\xC2\xA0" 1466 "\x0A\x0B\x0D\x0C\x0E\x0F\xC2\xA0"
1474 "\xC2\xB0\xC3\x80\xC3\x90\xC3\xA0" 1467 "\xC2\xB0\xC3\x80\xC3\x90\xC3\xA0"
1475 "\xC3\xB0\xE0\xA8\x80\xE0\xAC\x80" 1468 "\xC3\xB0\xE0\xA8\x80\xE0\xAC\x80"
1476 "\xE0\xB0\x80\xE0\xB4\x80\xE0\xB8" 1469 "\xE0\xB0\x80\xE0\xB4\x80\xE0\xB8"
1477 "\x80\xE0\xBC\x80\xEA\x80\x80\xEB" 1470 "\x80\xE0\xBC\x80\xEA\x80\x80\xEB"
1478 "\x80\x80\xEC\x80\x80\xED\x80\x80" 1471 "\x80\x80\xEC\x80\x80\xED\x80\x80"
1479 "\xEE\x80\x80\xEF\x80\x80"; 1472 "\xEE\x80\x80\xEF\x80\x80";
1480 const intptr_t expected[] = { 1473 const intptr_t expected[] = {
1481 0x000A, 0x000B, 0x000D, 0x000C, 0x000E, 0x000F, 0x00A0, 0x00B0, 1474 0x000A, 0x000B, 0x000D, 0x000C, 0x000E, 0x000F, 0x00A0, 0x00B0,
1482 0x00C0, 0x00D0, 0x00E0, 0x00F0, 0x0A00, 0x0B00, 0x0C00, 0x0D00, 1475 0x00C0, 0x00D0, 0x00E0, 0x00F0, 0x0A00, 0x0B00, 0x0C00, 0x0D00,
1483 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000 1476 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000
1484 }; 1477 };
1485 const String& str = String::Handle(String::New(src)); 1478 const String& str = String::Handle(String::New(src));
1486 EXPECT(str.IsTwoByteString()); 1479 EXPECT(str.IsTwoByteString());
1487 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); 1480 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]);
1488 EXPECT_EQ(expected_size, str.Length()); 1481 EXPECT_EQ(expected_size, str.Length());
1489 for (int i = 0; i < str.Length(); ++i) { 1482 for (int i = 0; i < str.Length(); ++i) {
1490 EXPECT_EQ(expected[i], str.CharAt(i)); 1483 EXPECT_EQ(expected[i], str.CharAt(i));
1491 } 1484 }
1492 } 1485 }
1493 1486
1494 // Create a 4-byte string from a UTF-8 string literal. 1487 // Create a SMP 2-byte string from a UTF-8 string literal.
1495 { 1488 {
1496 const char* src = 1489 const char* src =
1497 "\xF0\x9D\x91\xA0\xF0\x9D\x91\xA1" 1490 "\xF0\x9D\x91\xA0\xF0\x9D\x91\xA1"
1498 "\xF0\x9D\x91\xA2\xF0\x9D\x91\xA3"; 1491 "\xF0\x9D\x91\xA2\xF0\x9D\x91\xA3";
1499 const intptr_t expected[] = { 0x1D460, 0x1D461, 0x1D462, 0x1D463 }; 1492 const intptr_t expected[] = { 0x1D460, 0x1D461, 0x1D462, 0x1D463 };
1500 const String& str = String::Handle(String::New(src)); 1493 const String& str = String::Handle(String::New(src));
1501 EXPECT(str.IsFourByteString()); 1494 EXPECT(str.IsTwoByteString());
1502 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); 1495 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]);
1503 EXPECT_EQ(expected_size, str.Length()); 1496 EXPECT_EQ(expected_size, str.Length());
1504 for (int i = 0; i < str.Length(); ++i) { 1497 for (int i = 0; i < str.Length(); ++i) {
1505 EXPECT_EQ(expected[i], str.CharAt(i)); 1498 EXPECT_EQ(expected[i], str.CharAt(i));
1506 } 1499 }
1507 } 1500 }
1508 1501
1509 // Create a 4-byte string from UTF-8 encoded 2- and 4-byte 1502 // Create a SMP 2-byte string from UTF-8 encoded 2- and 4-byte
1510 // characters. 1503 // characters.
1511 { 1504 {
1512 const char* src = 1505 const char* src =
1513 "\xE0\xA8\x80\xE0\xAC\x80\xE0\xB0" 1506 "\xE0\xA8\x80\xE0\xAC\x80\xE0\xB0"
1514 "\x80\xE0\xB4\x80\xE0\xB8\x80\xE0" 1507 "\x80\xE0\xB4\x80\xE0\xB8\x80\xE0"
1515 "\xBC\x80\xEA\x80\x80\xEB\x80\x80" 1508 "\xBC\x80\xEA\x80\x80\xEB\x80\x80"
1516 "\xEC\x80\x80\xED\x80\x80\xEE\x80" 1509 "\xEC\x80\x80\xED\x80\x80\xEE\x80"
1517 "\x80\xEF\x80\x80\xF0\x9A\x80\x80" 1510 "\x80\xEF\x80\x80\xF0\x9A\x80\x80"
1518 "\xF0\x9B\x80\x80\xF0\x9D\x80\x80" 1511 "\xF0\x9B\x80\x80\xF0\x9D\x80\x80"
1519 "\xF0\x9E\x80\x80\xF0\x9F\x80\x80"; 1512 "\xF0\x9E\x80\x80\xF0\x9F\x80\x80";
1520 const intptr_t expected[] = { 1513 const intptr_t expected[] = {
1521 0x0A00, 0x0B00, 0x0C00, 0x0D00, 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000, 1514 0x0A00, 0x0B00, 0x0C00, 0x0D00, 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000,
1522 0xD000, 0xE000, 0xF000, 0x1A000, 0x1B000, 0x1D000, 0x1E000, 0x1F000 1515 0xD000, 0xE000, 0xF000, 0x1A000, 0x1B000, 0x1D000, 0x1E000, 0x1F000
1523 }; 1516 };
1524 const String& str = String::Handle(String::New(src)); 1517 const String& str = String::Handle(String::New(src));
1525 EXPECT(str.IsFourByteString()); 1518 EXPECT(str.IsTwoByteString());
1526 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); 1519 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]);
1527 EXPECT_EQ(expected_size, str.Length()); 1520 EXPECT_EQ(expected_size, str.Length());
1528 for (int i = 0; i < str.Length(); ++i) { 1521 for (int i = 0; i < str.Length(); ++i) {
1529 EXPECT_EQ(expected[i], str.CharAt(i)); 1522 EXPECT_EQ(expected[i], str.CharAt(i));
1530 } 1523 }
1531 } 1524 }
1532 1525
1533 // Create a 4-byte string from UTF-8 encoded 1-, 2- and 4-byte 1526 // Create a SMP 2-byte string from UTF-8 encoded 1-, 2- and 4-byte
1534 // characters. 1527 // characters.
1535 { 1528 {
1536 const char* src = 1529 const char* src =
1537 "\x0A\x0B\x0D\x0C\x0E\x0F\xC2\xA0" 1530 "\x0A\x0B\x0D\x0C\x0E\x0F\xC2\xA0"
1538 "\xC2\xB0\xC3\x80\xC3\x90\xC3\xA0" 1531 "\xC2\xB0\xC3\x80\xC3\x90\xC3\xA0"
1539 "\xC3\xB0\xE0\xA8\x80\xE0\xAC\x80" 1532 "\xC3\xB0\xE0\xA8\x80\xE0\xAC\x80"
1540 "\xE0\xB0\x80\xE0\xB4\x80\xE0\xB8" 1533 "\xE0\xB0\x80\xE0\xB4\x80\xE0\xB8"
1541 "\x80\xE0\xBC\x80\xEA\x80\x80\xEB" 1534 "\x80\xE0\xBC\x80\xEA\x80\x80\xEB"
1542 "\x80\x80\xEC\x80\x80\xED\x80\x80" 1535 "\x80\x80\xEC\x80\x80\xED\x80\x80"
1543 "\xEE\x80\x80\xEF\x80\x80\xF0\x9A" 1536 "\xEE\x80\x80\xEF\x80\x80\xF0\x9A"
1544 "\x80\x80\xF0\x9B\x80\x80\xF0\x9D" 1537 "\x80\x80\xF0\x9B\x80\x80\xF0\x9D"
1545 "\x80\x80\xF0\x9E\x80\x80\xF0\x9F" 1538 "\x80\x80\xF0\x9E\x80\x80\xF0\x9F"
1546 "\x80\x80"; 1539 "\x80\x80";
1547 const intptr_t expected[] = { 1540 const intptr_t expected[] = {
1548 0x000A, 0x000B, 0x000D, 0x000C, 0x000E, 0x000F, 0x00A0, 0x00B0, 1541 0x000A, 0x000B, 0x000D, 0x000C, 0x000E, 0x000F, 0x00A0, 0x00B0,
1549 0x00C0, 0x00D0, 0x00E0, 0x00F0, 0x0A00, 0x0B00, 0x0C00, 0x0D00, 1542 0x00C0, 0x00D0, 0x00E0, 0x00F0, 0x0A00, 0x0B00, 0x0C00, 0x0D00,
1550 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000, 1543 0x0E00, 0x0F00, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000,
1551 0x1A000, 0x1B000, 0x1D000, 0x1E000, 0x1F000 1544 0x1A000, 0x1B000, 0x1D000, 0x1E000, 0x1F000
1552 }; 1545 };
1553 const String& str = String::Handle(String::New(src)); 1546 const String& str = String::Handle(String::New(src));
1554 EXPECT(str.IsFourByteString()); 1547 EXPECT(str.IsTwoByteString());
1555 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); 1548 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]);
1556 EXPECT_EQ(expected_size, str.Length()); 1549 EXPECT_EQ(expected_size, str.Length());
1557 for (int i = 0; i < str.Length(); ++i) { 1550 for (int i = 0; i < str.Length(); ++i) {
1558 EXPECT_EQ(expected[i], str.CharAt(i)); 1551 EXPECT_EQ(expected[i], str.CharAt(i));
1559 } 1552 }
1560 } 1553 }
1561 } 1554 }
1562 1555
1563 1556
1564 TEST_CASE(ExternalOneByteString) { 1557 TEST_CASE(ExternalOneByteString) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); 1612 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93"));
1620 1613
1621 const String& substr = String::Handle(String::SubString(str, 1, 1)); 1614 const String& substr = String::Handle(String::SubString(str, 1, 1));
1622 EXPECT(!substr.IsExternalTwoByteString()); 1615 EXPECT(!substr.IsExternalTwoByteString());
1623 EXPECT(substr.IsTwoByteString()); 1616 EXPECT(substr.IsTwoByteString());
1624 EXPECT_EQ(1, substr.Length()); 1617 EXPECT_EQ(1, substr.Length());
1625 EXPECT(substr.Equals("\xE1\xBA\x85")); 1618 EXPECT(substr.Equals("\xE1\xBA\x85"));
1626 } 1619 }
1627 1620
1628 1621
1629 TEST_CASE(ExternalFourByteString) {
1630 uint32_t characters[] = { 0x1D5BF, 0x1D5C8, 0x1D5CE, 0x1D5CB };
1631 intptr_t len = ARRAY_SIZE(characters);
1632
1633 const String& str =
1634 String::Handle(
1635 ExternalFourByteString::New(characters, len, NULL, NULL, Heap::kNew));
1636 EXPECT(!str.IsFourByteString());
1637 EXPECT(str.IsExternalFourByteString());
1638 EXPECT_EQ(str.Length(), len);
1639 EXPECT(str.Equals("\xF0\x9D\x96\xBF\xF0\x9D\x97\x88"
1640 "\xF0\x9D\x97\x8E\xF0\x9D\x97\x8B"));
1641
1642 const String& copy = String::Handle(String::SubString(str, 0, len));
1643 EXPECT(!copy.IsExternalFourByteString());
1644 EXPECT(copy.IsFourByteString());
1645 EXPECT_EQ(len, copy.Length());
1646 EXPECT(copy.Equals(str));
1647
1648 const String& concat = String::Handle(String::Concat(str, str));
1649 EXPECT(!concat.IsExternalFourByteString());
1650 EXPECT(concat.IsFourByteString());
1651 EXPECT_EQ(len * 2, concat.Length());
1652 EXPECT(concat.Equals("\xF0\x9D\x96\xBF\xF0\x9D\x97\x88"
1653 "\xF0\x9D\x97\x8E\xF0\x9D\x97\x8B"
1654 "\xF0\x9D\x96\xBF\xF0\x9D\x97\x88"
1655 "\xF0\x9D\x97\x8E\xF0\x9D\x97\x8B"));
1656
1657 const String& substr = String::Handle(String::SubString(str, 1, 2));
1658 EXPECT(!substr.IsExternalFourByteString());
1659 EXPECT(substr.IsFourByteString());
1660 EXPECT_EQ(2, substr.Length());
1661 EXPECT(substr.Equals("\xF0\x9D\x97\x88\xF0\x9D\x97\x8E"));
1662 }
1663
1664
1665 TEST_CASE(Symbol) { 1622 TEST_CASE(Symbol) {
1666 const String& one = String::Handle(Symbols::New("Eins")); 1623 const String& one = String::Handle(Symbols::New("Eins"));
1667 EXPECT(one.IsSymbol()); 1624 EXPECT(one.IsSymbol());
1668 const String& two = String::Handle(Symbols::New("Zwei")); 1625 const String& two = String::Handle(Symbols::New("Zwei"));
1669 const String& three = String::Handle(Symbols::New("Drei")); 1626 const String& three = String::Handle(Symbols::New("Drei"));
1670 const String& four = String::Handle(Symbols::New("Vier")); 1627 const String& four = String::Handle(Symbols::New("Vier"));
1671 const String& five = String::Handle(Symbols::New("Fuenf")); 1628 const String& five = String::Handle(Symbols::New("Fuenf"));
1672 const String& six = String::Handle(Symbols::New("Sechs")); 1629 const String& six = String::Handle(Symbols::New("Sechs"));
1673 const String& seven = String::Handle(Symbols::New("Sieben")); 1630 const String& seven = String::Handle(Symbols::New("Sieben"));
1674 const String& eight = String::Handle(Symbols::New("Acht")); 1631 const String& eight = String::Handle(Symbols::New("Acht"));
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 " }\n" 2796 " }\n"
2840 " fooHelper();\n" 2797 " fooHelper();\n"
2841 " }\n" 2798 " }\n"
2842 "}\n" 2799 "}\n"
2843 "\n" 2800 "\n"
2844 "main() {\n" 2801 "main() {\n"
2845 " (() => new MyClass())();\n" 2802 " (() => new MyClass())();\n"
2846 "}\n"; 2803 "}\n";
2847 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2804 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2848 EXPECT_VALID(lib); 2805 EXPECT_VALID(lib);
2849 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("main"), 0, NULL); 2806 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
2850 EXPECT_ERROR( 2807 EXPECT_ERROR(
2851 result, 2808 result,
2852 "Unhandled exception:\n" 2809 "Unhandled exception:\n"
2853 "MyException\n" 2810 "MyException\n"
2854 "#0 baz (dart:test-lib:2:3)\n" 2811 "#0 baz (dart:test-lib:2:3)\n"
2855 "#1 _OtherClass._OtherClass._named (dart:test-lib:7:8)\n" 2812 "#1 _OtherClass._OtherClass._named (dart:test-lib:7:8)\n"
2856 "#2 globalVar= (dart:test-lib:12:3)\n" 2813 "#2 globalVar= (dart:test-lib:12:3)\n"
2857 "#3 _bar (dart:test-lib:16:3)\n" 2814 "#3 _bar (dart:test-lib:16:3)\n"
2858 "#4 MyClass.field (dart:test-lib:25:9)\n" 2815 "#4 MyClass.field (dart:test-lib:25:9)\n"
2859 "#5 MyClass.foo.fooHelper (dart:test-lib:30:7)\n" 2816 "#5 MyClass.foo.fooHelper (dart:test-lib:30:7)\n"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 isolate->heap()->CollectAllGarbage(); 3200 isolate->heap()->CollectAllGarbage();
3244 EXPECT(weak1.key() == Object::null()); 3201 EXPECT(weak1.key() == Object::null());
3245 EXPECT(weak1.value() == Object::null()); 3202 EXPECT(weak1.value() == Object::null());
3246 EXPECT(weak2.key() == Object::null()); 3203 EXPECT(weak2.key() == Object::null());
3247 EXPECT(weak2.value() == Object::null()); 3204 EXPECT(weak2.value() == Object::null());
3248 } 3205 }
3249 3206
3250 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3207 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3251 3208
3252 } // namespace dart 3209 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698