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

Unified Diff: runtime/vm/object_test.cc

Issue 100103011: Changes to support dprof and Observatory profiler UIs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object_test.cc
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index 8d93d307a97299637be975a8f285a4787bca1082..b4ab957b650d88d0528d3f0ce3eb52addc45180a 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -3468,17 +3468,21 @@ TEST_CASE(FindFieldIndex) {
TEST_CASE(FindFunctionIndex) {
+ // Tests both FindFunctionIndex and FindImplicitClosureFunctionIndex.
Ivan Posva 2014/01/03 01:52:17 Can you add the dispatcher lookups to the tests as
Cutch 2014/01/03 16:01:56 Done.
const char* kScriptChars =
"class A {\n"
" void a() {}\n"
- " void b() {}\n"
+ " void b() { return a; }\n"
"}\n"
"class B {\n"
" dynamic d() {}\n"
"}\n"
+ "var x;\n"
"test() {\n"
- " new A();\n"
+ " x = new A().b();\n"
+ " x();\n"
" new B();\n"
+ " return x;\n"
"}";
Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(h_lib);
@@ -3493,25 +3497,37 @@ TEST_CASE(FindFunctionIndex) {
const Function& func_a = Function::Handle(GetFunction(class_a, "a"));
const Function& func_b = Function::Handle(GetFunction(class_a, "b"));
const Function& func_d = Function::Handle(GetFunction(class_b, "d"));
+ EXPECT(func_a.HasImplicitClosureFunction());
+ const Function& func_x = Function::Handle(func_a.ImplicitClosureFunction());
intptr_t func_a_index = class_a.FindFunctionIndex(func_a);
intptr_t func_b_index = class_a.FindFunctionIndex(func_b);
intptr_t func_d_index = class_a.FindFunctionIndex(func_d);
+ intptr_t func_x_index = class_a.FindImplicitClosureFunctionIndex(func_x);
// Valid index.
EXPECT_GE(func_a_index, 0);
// Valid index.
EXPECT_GE(func_b_index, 0);
// Invalid index.
EXPECT_EQ(func_d_index, -1);
+ // Valid index.
+ EXPECT_GE(func_x_index, 0);
Function& func_a_from_index = Function::Handle();
func_a_from_index ^= class_a_funcs.At(func_a_index);
- ASSERT(!func_a_from_index.IsNull());
+ EXPECT(!func_a_from_index.IsNull());
// Same function.
EXPECT_EQ(func_a.raw(), func_a_from_index.raw());
Function& func_b_from_index = Function::Handle();
func_b_from_index ^= class_a_funcs.At(func_b_index);
- ASSERT(!func_b_from_index.IsNull());
+ EXPECT(!func_b_from_index.IsNull());
// Same function.
EXPECT_EQ(func_b.raw(), func_b_from_index.raw());
+ // Retrieve function a from x's index.
+ func_a_from_index ^= class_a_funcs.At(func_x_index);
+ EXPECT_EQ(func_a.raw(), func_a_from_index.raw());
+ EXPECT(func_a.HasImplicitClosureFunction());
+ Function& func_x_from_index = Function::Handle();
+ func_x_from_index ^= func_a_from_index.ImplicitClosureFunction();
+ EXPECT_EQ(func_x.raw(), func_x_from_index.raw());
}
@@ -3535,11 +3551,11 @@ TEST_CASE(FindClosureIndex) {
// Add closure function to class.
cls.AddClosureFunction(function);
- // Token position 0 should return a valid index.
- intptr_t good_closure_index = cls.FindClosureIndex(0);
+ // The closure should return a valid index.
+ intptr_t good_closure_index = cls.FindClosureIndex(function);
EXPECT_GE(good_closure_index, 0);
- // Token position 1 should return an invalid index.
- intptr_t bad_closure_index = cls.FindClosureIndex(1);
+ // The parent function should return an invalid index.
+ intptr_t bad_closure_index = cls.FindClosureIndex(parent);
EXPECT_EQ(bad_closure_index, -1);
// Retrieve closure function via index.

Powered by Google App Engine
This is Rietveld 408576698