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

Unified Diff: runtime/vm/object_test.cc

Issue 22916006: Move the begin token of explicit functions to the start of the function declaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 25e7fcbcc6ea44ce26669df35652765b1f56667e..42e894ee95f5ba9313e3f0142536c0a547f1e4a6 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -3214,6 +3214,14 @@ static RawFunction* GetFunction(const Class& cls, const char* name) {
}
+static RawFunction* GetStaticFunction(const Class& cls, const char* name) {
+ const Function& result = Function::Handle(cls.LookupStaticFunction(
+ String::Handle(String::New(name))));
+ EXPECT(!result.IsNull());
+ return result.raw();
+}
+
+
static RawField* GetField(const Class& cls, const char* name) {
const Field& field =
Field::Handle(cls.LookupField(String::Handle(String::New(name))));
@@ -3325,25 +3333,31 @@ TEST_CASE(Metadata) {
TEST_CASE(FunctionSourceFingerprint) {
const char* kScriptChars =
"class A {\n"
- " void test1(int a) {\n"
- " return a > 1 ? a + 1 : a;\n"
- " }\n"
- " void test2(int a) {\n"
+ " static void test1(int a) {\n"
hausner 2013/08/13 15:40:11 Why did you change the functions to static? Is it
Michael Lippautz (Google) 2013/08/13 18:07:34 Yes, it's because the fingerprint's intial value i
" return a > 1 ? a + 1 : a;\n"
" }\n"
- " void test3(a) {\n"
+ " static void test2(a) {\n"
" return a > 1 ? a + 1 : a;\n"
" }\n"
- " void test4(b) {\n"
+ " static void test3(b) {\n"
" return b > 1 ? b + 1 : b;\n"
" }\n"
- " void test5(b) {\n"
+ " static void test4(b) {\n"
" return b > 1 ? b - 1 : b;\n"
" }\n"
- " void test6(b) {\n"
+ " static void test5(b) {\n"
" return b > 1 ? b - 2 : b;\n"
" }\n"
- " void test7(b) {\n"
+ "}\n"
+ "class B {\n"
+ " static void /* Different declaration style. */\n"
+ " test1(int a) {\n"
+ " /* Returns a + 1 for a > 1, a otherwise. */\n"
+ " return a > 1 ?\n"
+ " a + 1 :\n"
+ " a;\n"
+ " }\n"
+ " static void test5(b) {\n"
" return b > 1 ?\n"
" b - 2 : b;\n"
" }\n"
@@ -3356,19 +3370,29 @@ TEST_CASE(FunctionSourceFingerprint) {
const Class& class_a = Class::Handle(
lib.LookupClass(String::Handle(Symbols::New("A")), NULL));
- const Function& test1 = Function::Handle(GetFunction(class_a, "test1"));
- const Function& test2 = Function::Handle(GetFunction(class_a, "test2"));
- const Function& test3 = Function::Handle(GetFunction(class_a, "test3"));
- const Function& test4 = Function::Handle(GetFunction(class_a, "test4"));
- const Function& test5 = Function::Handle(GetFunction(class_a, "test5"));
- const Function& test6 = Function::Handle(GetFunction(class_a, "test6"));
- const Function& test7 = Function::Handle(GetFunction(class_a, "test7"));
- EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint());
- EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint());
- EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint());
- EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint());
- EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint());
- EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint());
+ const Class& class_b = Class::Handle(
+ lib.LookupClass(String::Handle(Symbols::New("B")), NULL));
+ const Function& a_test1 = Function::Handle(GetStaticFunction(
hausner 2013/08/13 15:40:11 Nit: could you reformat this as const Function& a
Michael Lippautz (Google) 2013/08/13 18:07:34 Done.
+ class_a, "test1"));
+ const Function& b_test1 = Function::Handle(GetStaticFunction(
+ class_b, "test1"));
+ const Function& a_test2 = Function::Handle(GetStaticFunction(
+ class_a, "test2"));
+ const Function& a_test3 = Function::Handle(GetStaticFunction(
+ class_a, "test3"));
+ const Function& a_test4 = Function::Handle(GetStaticFunction(
+ class_a, "test4"));
+ const Function& a_test5 = Function::Handle(GetStaticFunction(
+ class_a, "test5"));
+ const Function& b_test5 = Function::Handle(GetStaticFunction(
+ class_b, "test5"));
+
+ EXPECT_EQ(a_test1.SourceFingerprint(), b_test1.SourceFingerprint());
+ EXPECT_NE(a_test1.SourceFingerprint(), a_test2.SourceFingerprint());
+ EXPECT_NE(a_test2.SourceFingerprint(), a_test3.SourceFingerprint());
+ EXPECT_NE(a_test3.SourceFingerprint(), a_test4.SourceFingerprint());
+ EXPECT_NE(a_test4.SourceFingerprint(), a_test5.SourceFingerprint());
+ EXPECT_EQ(a_test5.SourceFingerprint(), b_test5.SourceFingerprint());
}
} // namespace dart
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698