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

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

Issue 1469243002: Remove dead code (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « 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 "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 3799 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 // Same field. 3810 // Same field.
3811 EXPECT_EQ(field_a.raw(), field_a_from_index.raw()); 3811 EXPECT_EQ(field_a.raw(), field_a_from_index.raw());
3812 Field& field_b_from_index = Field::Handle(); 3812 Field& field_b_from_index = Field::Handle();
3813 field_b_from_index ^= class_a_fields.At(field_b_index); 3813 field_b_from_index ^= class_a_fields.At(field_b_index);
3814 ASSERT(!field_b_from_index.IsNull()); 3814 ASSERT(!field_b_from_index.IsNull());
3815 // Same field. 3815 // Same field.
3816 EXPECT_EQ(field_b.raw(), field_b_from_index.raw()); 3816 EXPECT_EQ(field_b.raw(), field_b_from_index.raw());
3817 } 3817 }
3818 3818
3819 3819
3820 TEST_CASE(FindFunctionIndex) {
3821 // Tests both FindFunctionIndex and FindImplicitClosureFunctionIndex.
3822 const char* kScriptChars =
3823 "class A {\n"
3824 " void a() {}\n"
3825 " Function b() { return a; }\n"
3826 "}\n"
3827 "class B {\n"
3828 " dynamic d() {}\n"
3829 "}\n"
3830 "var x;\n"
3831 "test() {\n"
3832 " x = new A().b();\n"
3833 " x();\n"
3834 " new B();\n"
3835 " return x;\n"
3836 "}";
3837 Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL);
3838 EXPECT_VALID(h_lib);
3839 Dart_Handle result = Dart_Invoke(h_lib, NewString("test"), 0, NULL);
3840 EXPECT_VALID(result);
3841 Library& lib = Library::Handle();
3842 lib ^= Api::UnwrapHandle(h_lib);
3843 EXPECT(!lib.IsNull());
3844 const Class& class_a = Class::Handle(GetClass(lib, "A"));
3845 const Class& class_b = Class::Handle(GetClass(lib, "B"));
3846 const Function& func_a = Function::Handle(GetFunction(class_a, "a"));
3847 const Function& func_b = Function::Handle(GetFunction(class_a, "b"));
3848 const Function& func_d = Function::Handle(GetFunction(class_b, "d"));
3849 EXPECT(func_a.HasImplicitClosureFunction());
3850 const Function& func_x = Function::Handle(func_a.ImplicitClosureFunction());
3851 intptr_t func_a_index = class_a.FindFunctionIndex(func_a);
3852 intptr_t func_b_index = class_a.FindFunctionIndex(func_b);
3853 intptr_t func_d_index = class_a.FindFunctionIndex(func_d);
3854 intptr_t func_x_index = class_a.FindImplicitClosureFunctionIndex(func_x);
3855 // Valid index.
3856 EXPECT_GE(func_a_index, 0);
3857 // Valid index.
3858 EXPECT_GE(func_b_index, 0);
3859 // Invalid index.
3860 EXPECT_EQ(func_d_index, -1);
3861 // Valid index.
3862 EXPECT_GE(func_x_index, 0);
3863 Function& func_a_from_index = Function::Handle();
3864 func_a_from_index ^= class_a.FunctionFromIndex(func_a_index);
3865 EXPECT(!func_a_from_index.IsNull());
3866 // Same function.
3867 EXPECT_EQ(func_a.raw(), func_a_from_index.raw());
3868 Function& func_b_from_index = Function::Handle();
3869 func_b_from_index ^= class_a.FunctionFromIndex(func_b_index);
3870 EXPECT(!func_b_from_index.IsNull());
3871 // Same function.
3872 EXPECT_EQ(func_b.raw(), func_b_from_index.raw());
3873 // Retrieve implicit closure function.
3874 Function& func_x_from_index = Function::Handle();
3875 func_x_from_index ^= class_a.ImplicitClosureFunctionFromIndex(func_x_index);
3876 EXPECT_EQ(func_x.raw(), func_x_from_index.raw());
3877 }
3878
3879
3880 TEST_CASE(FindClosureIndex) { 3820 TEST_CASE(FindClosureIndex) {
3881 // Allocate the class first. 3821 // Allocate the class first.
3882 const String& class_name = String::Handle(Symbols::New("MyClass")); 3822 const String& class_name = String::Handle(Symbols::New("MyClass"));
3883 const Script& script = Script::Handle(); 3823 const Script& script = Script::Handle();
3884 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 3824 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
3885 const Array& functions = Array::Handle(Array::New(1)); 3825 const Array& functions = Array::Handle(Array::New(1));
3886 const Isolate* iso = Isolate::Current(); 3826 const Isolate* iso = Isolate::Current();
3887 3827
3888 Function& parent = Function::Handle(); 3828 Function& parent = Function::Handle();
3889 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 3829 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
4789 String& test = String::Handle(); 4729 String& test = String::Handle();
4790 String& result = String::Handle(); 4730 String& result = String::Handle();
4791 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4731 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4792 test = String::New(tests[i].in); 4732 test = String::New(tests[i].in);
4793 result = String::IdentifierPrettyName(test); 4733 result = String::IdentifierPrettyName(test);
4794 EXPECT_STREQ(tests[i].out, result.ToCString()); 4734 EXPECT_STREQ(tests[i].out, result.ToCString());
4795 } 4735 }
4796 } 4736 }
4797 4737
4798 } // namespace dart 4738 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698