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

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

Issue 2666133002: Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run w… (Closed)
Patch Set: Fixed name of UNIT_TEST_CASE macro Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/boolfield_test.cc ('k') | runtime/vm/cpu_test.cc » ('j') | 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/class_finalizer.h" 6 #include "vm/class_finalizer.h"
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/safepoint.h" 11 #include "vm/safepoint.h"
12 #include "vm/symbols.h" 12 #include "vm/symbols.h"
13 #include "vm/thread_pool.h" 13 #include "vm/thread_pool.h"
14 #include "vm/unit_test.h" 14 #include "vm/unit_test.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 VM_TEST_CASE(CompileScript) { 18 ISOLATE_UNIT_TEST_CASE(CompileScript) {
19 const char* kScriptChars = 19 const char* kScriptChars =
20 "class A {\n" 20 "class A {\n"
21 " static foo() { return 42; }\n" 21 " static foo() { return 42; }\n"
22 "}\n"; 22 "}\n";
23 String& url = String::Handle(String::New("dart-test:CompileScript")); 23 String& url = String::Handle(String::New("dart-test:CompileScript"));
24 String& source = String::Handle(String::New(kScriptChars)); 24 String& source = String::Handle(String::New(kScriptChars));
25 Script& script = 25 Script& script =
26 Script::Handle(Script::New(url, source, RawScript::kScriptTag)); 26 Script::Handle(Script::New(url, source, RawScript::kScriptTag));
27 Library& lib = Library::Handle(Library::CoreLibrary()); 27 Library& lib = Library::Handle(Library::CoreLibrary());
28 EXPECT(CompilerTest::TestCompileScript(lib, script)); 28 EXPECT(CompilerTest::TestCompileScript(lib, script));
29 } 29 }
30 30
31 31
32 VM_TEST_CASE(CompileFunction) { 32 ISOLATE_UNIT_TEST_CASE(CompileFunction) {
33 const char* kScriptChars = 33 const char* kScriptChars =
34 "class A {\n" 34 "class A {\n"
35 " static foo() { return 42; }\n" 35 " static foo() { return 42; }\n"
36 " static moo() {\n" 36 " static moo() {\n"
37 " // A.foo();\n" 37 " // A.foo();\n"
38 " }\n" 38 " }\n"
39 "}\n"; 39 "}\n";
40 String& url = String::Handle(String::New("dart-test:CompileFunction")); 40 String& url = String::Handle(String::New("dart-test:CompileFunction"));
41 String& source = String::Handle(String::New(kScriptChars)); 41 String& source = String::Handle(String::New(kScriptChars));
42 Script& script = 42 Script& script =
(...skipping 19 matching lines...) Expand all
62 EXPECT(!function_moo.IsNull()); 62 EXPECT(!function_moo.IsNull());
63 63
64 EXPECT(CompilerTest::TestCompileFunction(function_moo)); 64 EXPECT(CompilerTest::TestCompileFunction(function_moo));
65 EXPECT(function_moo.HasCode()); 65 EXPECT(function_moo.HasCode());
66 function_source = function_moo.GetSource(); 66 function_source = function_moo.GetSource();
67 EXPECT_STREQ("static moo() {\n // A.foo();\n }", 67 EXPECT_STREQ("static moo() {\n // A.foo();\n }",
68 function_source.ToCString()); 68 function_source.ToCString());
69 } 69 }
70 70
71 71
72 VM_TEST_CASE(CompileFunctionOnHelperThread) { 72 ISOLATE_UNIT_TEST_CASE(CompileFunctionOnHelperThread) {
73 // Create a simple function and compile it without optimization. 73 // Create a simple function and compile it without optimization.
74 const char* kScriptChars = 74 const char* kScriptChars =
75 "class A {\n" 75 "class A {\n"
76 " static foo() { return 42; }\n" 76 " static foo() { return 42; }\n"
77 "}\n"; 77 "}\n";
78 String& url = 78 String& url =
79 String::Handle(String::New("dart-test:CompileFunctionOnHelperThread")); 79 String::Handle(String::New("dart-test:CompileFunctionOnHelperThread"));
80 String& source = String::Handle(String::New(kScriptChars)); 80 String& source = String::Handle(String::New(kScriptChars));
81 Script& script = 81 Script& script =
82 Script::Handle(Script::New(url, source, RawScript::kScriptTag)); 82 Script::Handle(Script::New(url, source, RawScript::kScriptTag));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const Class& receiver_cls = Class::Handle(obj.clazz()); 177 const Class& receiver_cls = Class::Handle(obj.clazz());
178 val = Instance::Cast(obj).Evaluate( 178 val = Instance::Cast(obj).Evaluate(
179 receiver_cls, expr_text, Array::empty_array(), Array::empty_array()); 179 receiver_cls, expr_text, Array::empty_array(), Array::empty_array());
180 EXPECT(!val.IsNull()); 180 EXPECT(!val.IsNull());
181 EXPECT(!val.IsError()); 181 EXPECT(!val.IsError());
182 EXPECT(val.IsString()); 182 EXPECT(val.IsString());
183 EXPECT_STREQ("Herr Nilsson 100.", val.ToCString()); 183 EXPECT_STREQ("Herr Nilsson 100.", val.ToCString());
184 } 184 }
185 185
186 186
187 VM_TEST_CASE(EvalExpressionWithLazyCompile) { 187 ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) {
188 Library& lib = Library::Handle(Library::CoreLibrary()); 188 Library& lib = Library::Handle(Library::CoreLibrary());
189 189
190 const String& expression = String::Handle( 190 const String& expression = String::Handle(
191 String::New("(){ return (){ return (){ return 3 + 4; }(); }(); }()")); 191 String::New("(){ return (){ return (){ return 3 + 4; }(); }(); }()"));
192 Object& val = Object::Handle(); 192 Object& val = Object::Handle();
193 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); 193 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array());
194 194
195 EXPECT(!val.IsNull()); 195 EXPECT(!val.IsNull());
196 EXPECT(!val.IsError()); 196 EXPECT(!val.IsError());
197 EXPECT(val.IsInteger()); 197 EXPECT(val.IsInteger());
198 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 198 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
199 } 199 }
200 200
201 201
202 VM_TEST_CASE(EvalExpressionExhaustCIDs) { 202 ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) {
203 Library& lib = Library::Handle(Library::CoreLibrary()); 203 Library& lib = Library::Handle(Library::CoreLibrary());
204 204
205 const String& expression = String::Handle(String::New("3 + 4")); 205 const String& expression = String::Handle(String::New("3 + 4"));
206 Object& val = Object::Handle(); 206 Object& val = Object::Handle();
207 207
208 // Run once to ensure everything we touch is compiled. 208 // Run once to ensure everything we touch is compiled.
209 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); 209 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array());
210 EXPECT(!val.IsNull()); 210 EXPECT(!val.IsNull());
211 EXPECT(!val.IsError()); 211 EXPECT(!val.IsError());
212 EXPECT(val.IsInteger()); 212 EXPECT(val.IsInteger());
213 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 213 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
214 214
215 intptr_t initial_class_table_size = 215 intptr_t initial_class_table_size =
216 Isolate::Current()->class_table()->NumCids(); 216 Isolate::Current()->class_table()->NumCids();
217 217
218 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); 218 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array());
219 EXPECT(!val.IsNull()); 219 EXPECT(!val.IsNull());
220 EXPECT(!val.IsError()); 220 EXPECT(!val.IsError());
221 EXPECT(val.IsInteger()); 221 EXPECT(val.IsInteger());
222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
223 223
224 intptr_t final_class_table_size = 224 intptr_t final_class_table_size =
225 Isolate::Current()->class_table()->NumCids(); 225 Isolate::Current()->class_table()->NumCids();
226 // Eval should not eat into this non-renewable resource. 226 // Eval should not eat into this non-renewable resource.
227 EXPECT_EQ(initial_class_table_size, final_class_table_size); 227 EXPECT_EQ(initial_class_table_size, final_class_table_size);
228 } 228 }
229 229
230 } // namespace dart 230 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/boolfield_test.cc ('k') | runtime/vm/cpu_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698