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

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

Issue 100603011: Add GrowableObjectArray::ToUserCString(). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« runtime/vm/object.cc ('K') | « runtime/vm/object.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 (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 "vm/assembler.h" 5 #include "vm/assembler.h"
6 #include "vm/bigint_operations.h" 6 #include "vm/bigint_operations.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 "var toolong = " 3636 "var toolong = "
3637 "'01234567890123456789012345678901234567890123456789howdy';\n" 3637 "'01234567890123456789012345678901234567890123456789howdy';\n"
3638 "var toolong2 = " 3638 "var toolong2 = "
3639 "'0123456789012345678901234567890123\\t567890123456789howdy';\n" 3639 "'0123456789012345678901234567890123\\t567890123456789howdy';\n"
3640 "var toolong3 = " 3640 "var toolong3 = "
3641 "'012345678901234567890123456789\\u0001567890123456789howdy';\n" 3641 "'012345678901234567890123456789\\u0001567890123456789howdy';\n"
3642 "\n" 3642 "\n"
3643 "class _Cobra { }\n" 3643 "class _Cobra { }\n"
3644 "var instance = new _Cobra();\n" 3644 "var instance = new _Cobra();\n"
3645 "\n" 3645 "\n"
3646 "var empty_list = [];\n"
3646 "var simple_list = [1,2,'otter'];\n" 3647 "var simple_list = [1,2,'otter'];\n"
3648 "var nested_list = [[[[1]]],[2,'otter']];\n"
3649 "var deeply_nested_list = [[[[[1]]]],[2,'otter']];\n"
3650 "var toolong_list = "
3651 "['0123456789','0123456789','0123456789','0123456789'];\n"
3652 "var toolong2_list = [toolong];\n"
3653 "var justenough_list = [0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,99];"
3654 "var toolong3_list = [0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4];"
3647 "\n" 3655 "\n"
3648 "var simple_map = {1: 2, 2: 'otter'};\n"; 3656 "var simple_map = {1: 2, 2: 'otter'};\n";
3649 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3657 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3650 EXPECT_VALID(lib); 3658 EXPECT_VALID(lib);
3651 3659
3652 Instance& obj = Instance::Handle(); 3660 Instance& obj = Instance::Handle();
3653 Dart_Handle result; 3661 Dart_Handle result;
3654 3662
3655 // Simple string. 3663 // Simple string.
3656 result = Dart_GetField(lib, NewString("simple")); 3664 result = Dart_GetField(lib, NewString("simple"));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 obj ^= Api::UnwrapHandle(result); 3705 obj ^= Api::UnwrapHandle(result);
3698 EXPECT_STREQ("\"012345678901234567890123456789\"...", 3706 EXPECT_STREQ("\"012345678901234567890123456789\"...",
3699 obj.ToUserCString()); 3707 obj.ToUserCString());
3700 3708
3701 // Instance of a class. 3709 // Instance of a class.
3702 result = Dart_GetField(lib, NewString("instance")); 3710 result = Dart_GetField(lib, NewString("instance"));
3703 EXPECT_VALID(result); 3711 EXPECT_VALID(result);
3704 obj ^= Api::UnwrapHandle(result); 3712 obj ^= Api::UnwrapHandle(result);
3705 EXPECT_STREQ("Instance of '_Cobra'", obj.ToUserCString()); 3713 EXPECT_STREQ("Instance of '_Cobra'", obj.ToUserCString());
3706 3714
3715 // Empty list.
3716 result = Dart_GetField(lib, NewString("empty_list"));
3717 EXPECT_VALID(result);
3718 obj ^= Api::UnwrapHandle(result);
3719 EXPECT_STREQ("[]", obj.ToUserCString());
3720
3707 // Simple list. 3721 // Simple list.
3708 //
3709 // TODO(turnidge): Consider showing something like: [1, 2, 'otter'].
3710 result = Dart_GetField(lib, NewString("simple_list")); 3722 result = Dart_GetField(lib, NewString("simple_list"));
3711 EXPECT_VALID(result); 3723 EXPECT_VALID(result);
3712 obj ^= Api::UnwrapHandle(result); 3724 obj ^= Api::UnwrapHandle(result);
3713 EXPECT_STREQ("Instance(length:3) of '_GrowableList'", 3725 EXPECT_STREQ("[1,2,\"otter\"]", obj.ToUserCString());
3726
3727 // Nested list.
3728 result = Dart_GetField(lib, NewString("nested_list"));
3729 EXPECT_VALID(result);
3730 obj ^= Api::UnwrapHandle(result);
3731 EXPECT_STREQ("[[[[1]]],[2,\"otter\"]]", obj.ToUserCString());
3732
3733 // Deeply ested list.
3734 result = Dart_GetField(lib, NewString("deeply_nested_list"));
3735 EXPECT_VALID(result);
3736 obj ^= Api::UnwrapHandle(result);
3737 EXPECT_STREQ("[[[[[...]]]],[2,\"otter\"]]", obj.ToUserCString());
3738
3739 // Truncation.
3740 result = Dart_GetField(lib, NewString("toolong_list"));
3741 EXPECT_VALID(result);
3742 obj ^= Api::UnwrapHandle(result);
3743 EXPECT_STREQ("[\"0123456789\",\"012345\"...,...](length:4)",
3744 obj.ToUserCString());
3745
3746 // More truncation.
3747 result = Dart_GetField(lib, NewString("toolong2_list"));
3748 EXPECT_VALID(result);
3749 obj ^= Api::UnwrapHandle(result);
3750 EXPECT_STREQ("[\"012345678901234567890123456789012\"...]",
3751 obj.ToUserCString());
3752
3753 // Just fits.
3754 result = Dart_GetField(lib, NewString("justenough_list"));
3755 EXPECT_VALID(result);
3756 obj ^= Api::UnwrapHandle(result);
3757 EXPECT_STREQ("[0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,99]",
3758 obj.ToUserCString());
3759
3760 // Just too big, small elements.
3761 result = Dart_GetField(lib, NewString("toolong3_list"));
3762 EXPECT_VALID(result);
3763 obj ^= Api::UnwrapHandle(result);
3764 EXPECT_STREQ("[0,1,2,3,4,0,1,2,3,4,0,1,...](length:20)",
3714 obj.ToUserCString()); 3765 obj.ToUserCString());
3715 3766
3716 // Simple map. 3767 // Simple map.
3717 // 3768 //
3718 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} 3769 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'}
3719 result = Dart_GetField(lib, NewString("simple_map")); 3770 result = Dart_GetField(lib, NewString("simple_map"));
3720 EXPECT_VALID(result); 3771 EXPECT_VALID(result);
3721 obj ^= Api::UnwrapHandle(result); 3772 obj ^= Api::UnwrapHandle(result);
3722 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); 3773 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString());
3723 } 3774 }
3724 3775
3725 } // namespace dart 3776 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698