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

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

Issue 11416120: Add source fingerprint computation to function. Will be used to detect unexpected changes of functi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
« 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/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/class_finalizer.h"
8 #include "vm/isolate.h" 9 #include "vm/isolate.h"
9 #include "vm/object.h" 10 #include "vm/object.h"
10 #include "vm/object_store.h" 11 #include "vm/object_store.h"
11 #include "vm/symbols.h" 12 #include "vm/symbols.h"
12 #include "vm/unit_test.h" 13 #include "vm/unit_test.h"
13 14
14 namespace dart { 15 namespace dart {
15 16
16 TEST_CASE(Class) { 17 TEST_CASE(Class) {
17 // Allocate the class first. 18 // Allocate the class first.
(...skipping 3066 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 weak2.set_key(key); 3085 weak2.set_key(key);
3085 weak2.set_value(value2); 3086 weak2.set_value(value2);
3086 } 3087 }
3087 isolate->heap()->CollectAllGarbage(); 3088 isolate->heap()->CollectAllGarbage();
3088 EXPECT(weak1.key() == Object::null()); 3089 EXPECT(weak1.key() == Object::null());
3089 EXPECT(weak1.value() == Object::null()); 3090 EXPECT(weak1.value() == Object::null());
3090 EXPECT(weak2.key() == Object::null()); 3091 EXPECT(weak2.key() == Object::null());
3091 EXPECT(weak2.value() == Object::null()); 3092 EXPECT(weak2.value() == Object::null());
3092 } 3093 }
3093 3094
3095
3096 static RawFunction* GetFunction(const Class& cls, const char* name) {
3097 const Function& result = Function::Handle(cls.LookupDynamicFunction(
3098 String::Handle(String::New(name))));
3099 ASSERT(!result.IsNull());
3100 return result.raw();
3101 }
3102
3103
3104 TEST_CASE(FunctionSourceFingerprint) {
3105 const char* kScriptChars =
3106 "class A {\n"
3107 " void test1(int a) {\n"
3108 " return a > 1 ? a + 1 : a;\n"
3109 " }\n"
3110 " void test2(int a) {\n"
3111 " return a > 1 ? a + 1 : a;\n"
3112 " }\n"
3113 " void test3(a) {\n"
3114 " return a > 1 ? a + 1 : a;\n"
3115 " }\n"
3116 " void test4(b) {\n"
3117 " return b > 1 ? b + 1 : b;\n"
3118 " }\n"
3119 " void test5(b) {\n"
3120 " return b > 1 ? b - 1 : b;\n"
3121 " }\n"
3122 " void test6(b) {\n"
3123 " return b > 1 ? b - 2 : b;\n"
3124 " }\n"
3125 " void test7(b) {\n"
3126 " return b > 1 ?\n"
3127 " b - 2 : b;\n"
3128 " }\n"
3129 "}";
3130 TestCase::LoadTestScript(kScriptChars, NULL);
3131 EXPECT(ClassFinalizer::FinalizePendingClasses());
3132 const String& name = String::Handle(String::New(TestCase::url()));
3133 const Library& lib = Library::Handle(Library::LookupLibrary(name));
3134 EXPECT(!lib.IsNull());
3135
3136 const Class& class_a = Class::Handle(
3137 lib.LookupClass(String::Handle(Symbols::New("A"))));
3138 const Function& test1 = Function::Handle(GetFunction(class_a, "test1"));
3139 const Function& test2 = Function::Handle(GetFunction(class_a, "test2"));
3140 const Function& test3 = Function::Handle(GetFunction(class_a, "test3"));
3141 const Function& test4 = Function::Handle(GetFunction(class_a, "test4"));
3142 const Function& test5 = Function::Handle(GetFunction(class_a, "test5"));
3143 const Function& test6 = Function::Handle(GetFunction(class_a, "test6"));
3144 const Function& test7 = Function::Handle(GetFunction(class_a, "test7"));
3145 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint());
3146 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint());
3147 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint());
3148 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint());
3149 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint());
3150 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint());
3151 }
3152
3094 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3153 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3095 3154
3096 } // namespace dart 3155 } // 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