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

Side by Side Diff: vm/dart_entry_test.cc

Issue 11648006: Create read only handles for empty_array and sentinel objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/debugger.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/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 21 matching lines...) Expand all
32 EXPECT(ClassFinalizer::FinalizePendingClasses()); 32 EXPECT(ClassFinalizer::FinalizePendingClasses());
33 Class& cls = Class::Handle( 33 Class& cls = Class::Handle(
34 lib.LookupClass(String::Handle(Symbols::New("A")))); 34 lib.LookupClass(String::Handle(Symbols::New("A"))));
35 EXPECT(!cls.IsNull()); 35 EXPECT(!cls.IsNull());
36 String& name = String::Handle(String::New("foo")); 36 String& name = String::Handle(String::New("foo"));
37 Function& function = Function::Handle(cls.LookupStaticFunction(name)); 37 Function& function = Function::Handle(cls.LookupStaticFunction(name));
38 EXPECT(!function.IsNull()); 38 EXPECT(!function.IsNull());
39 39
40 EXPECT(CompilerTest::TestCompileFunction(function)); 40 EXPECT(CompilerTest::TestCompileFunction(function));
41 EXPECT(function.HasCode()); 41 EXPECT(function.HasCode());
42 const Array& args = Array::Handle(Object::empty_array()); 42 const Smi& retval = Smi::Handle(reinterpret_cast<RawSmi*>(
43 const Smi& retval = Smi::Handle( 43 DartEntry::InvokeStatic(function, Object::empty_array())));
44 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, args)));
45 EXPECT_EQ(Smi::New(42), retval.raw()); 44 EXPECT_EQ(Smi::New(42), retval.raw());
46 } 45 }
47 46
48 47
49 TEST_CASE(InvokeStatic_CompileError) { 48 TEST_CASE(InvokeStatic_CompileError) {
50 const char* kScriptChars = 49 const char* kScriptChars =
51 "class A {\n" 50 "class A {\n"
52 " static foo() { return ++++; }\n" 51 " static foo() { return ++++; }\n"
53 "}\n"; 52 "}\n";
54 String& url = String::Handle(String::New("dart-test:DartEntry")); 53 String& url = String::Handle(String::New("dart-test:DartEntry"));
55 String& source = String::Handle(String::New(kScriptChars)); 54 String& source = String::Handle(String::New(kScriptChars));
56 Script& script = Script::Handle(Script::New(url, 55 Script& script = Script::Handle(Script::New(url,
57 source, 56 source,
58 RawScript::kScriptTag)); 57 RawScript::kScriptTag));
59 Library& lib = Library::Handle(Library::CoreLibrary()); 58 Library& lib = Library::Handle(Library::CoreLibrary());
60 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); 59 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
61 EXPECT(ClassFinalizer::FinalizePendingClasses()); 60 EXPECT(ClassFinalizer::FinalizePendingClasses());
62 Class& cls = Class::Handle( 61 Class& cls = Class::Handle(
63 lib.LookupClass(String::Handle(Symbols::New("A")))); 62 lib.LookupClass(String::Handle(Symbols::New("A"))));
64 EXPECT(!cls.IsNull()); 63 EXPECT(!cls.IsNull());
65 String& name = String::Handle(String::New("foo")); 64 String& name = String::Handle(String::New("foo"));
66 Function& function = Function::Handle(cls.LookupStaticFunction(name)); 65 Function& function = Function::Handle(cls.LookupStaticFunction(name));
67 EXPECT(!function.IsNull()); 66 EXPECT(!function.IsNull());
68 GrowableArray<const Object*> arguments; 67 GrowableArray<const Object*> arguments;
69 const Array& args = Array::Handle(Object::empty_array()); 68 const Object& retval = Object::Handle(
70 const Object& retval = Object::Handle(DartEntry::InvokeStatic(function, 69 DartEntry::InvokeStatic(function, Object::empty_array()));
71 args));
72 EXPECT(retval.IsError()); 70 EXPECT(retval.IsError());
73 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); 71 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString());
74 } 72 }
75 73
76 74
77 TEST_CASE(InvokeDynamic_CompileError) { 75 TEST_CASE(InvokeDynamic_CompileError) {
78 const char* kScriptChars = 76 const char* kScriptChars =
79 "class A {\n" 77 "class A {\n"
80 " foo() { return ++++; }\n" 78 " foo() { return ++++; }\n"
81 "}\n"; 79 "}\n";
(...skipping 29 matching lines...) Expand all
111 args.SetAt(0, instance); 109 args.SetAt(0, instance);
112 const Object& retval = Object::Handle(DartEntry::InvokeDynamic(function, 110 const Object& retval = Object::Handle(DartEntry::InvokeDynamic(function,
113 args)); 111 args));
114 EXPECT(retval.IsError()); 112 EXPECT(retval.IsError());
115 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); 113 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString());
116 } 114 }
117 115
118 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. 116 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64.
119 117
120 } // namespace dart 118 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698