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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 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
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/find_code_object_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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 12
13 #define FUNCTION_NAME(name) UnhandledExcp_##name 13 #define FUNCTION_NAME(name) UnhandledExcp_##name
14 #define REGISTER_FUNCTION(name, count) \ 14 #define REGISTER_FUNCTION(name, count) {"" #name, FUNCTION_NAME(name), count},
15 { ""#name, FUNCTION_NAME(name), count },
16 15
17 16
18 void FUNCTION_NAME(Unhandled_equals)(Dart_NativeArguments args) { 17 void FUNCTION_NAME(Unhandled_equals)(Dart_NativeArguments args) {
19 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 18 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
20 const Instance& expected = Instance::CheckedHandle(arguments->NativeArgAt(0)); 19 const Instance& expected = Instance::CheckedHandle(arguments->NativeArgAt(0));
21 const Instance& actual = Instance::CheckedHandle(arguments->NativeArgAt(1)); 20 const Instance& actual = Instance::CheckedHandle(arguments->NativeArgAt(1));
22 if (!expected.CanonicalizeEquals(actual)) { 21 if (!expected.CanonicalizeEquals(actual)) {
23 OS::Print("expected: '%s' actual: '%s'\n", 22 OS::Print("expected: '%s' actual: '%s'\n", expected.ToCString(),
24 expected.ToCString(), actual.ToCString()); 23 actual.ToCString());
25 FATAL("Unhandled_equals fails.\n"); 24 FATAL("Unhandled_equals fails.\n");
26 } 25 }
27 } 26 }
28 27
29 28
30 void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) { 29 void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) {
31 // Invoke the specified entry point. 30 // Invoke the specified entry point.
32 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second")); 31 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second"));
33 Dart_Handle result = Dart_Invoke(cls, 32 Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, NULL);
34 NewString("method2"),
35 0,
36 NULL);
37 ASSERT(Dart_IsError(result)); 33 ASSERT(Dart_IsError(result));
38 ASSERT(Dart_ErrorHasException(result)); 34 ASSERT(Dart_ErrorHasException(result));
39 return; 35 return;
40 } 36 }
41 37
42 38
43 void FUNCTION_NAME(Unhandled_invoke2)(Dart_NativeArguments args) { 39 void FUNCTION_NAME(Unhandled_invoke2)(Dart_NativeArguments args) {
44 // Invoke the specified entry point. 40 // Invoke the specified entry point.
45 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second")); 41 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second"));
46 Dart_Handle result = Dart_Invoke(cls, 42 Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, NULL);
47 NewString("method2"),
48 0,
49 NULL);
50 ASSERT(Dart_IsError(result)); 43 ASSERT(Dart_IsError(result));
51 ASSERT(Dart_ErrorHasException(result)); 44 ASSERT(Dart_ErrorHasException(result));
52 Dart_Handle exception = Dart_ErrorGetException(result); 45 Dart_Handle exception = Dart_ErrorGetException(result);
53 ASSERT(!Dart_IsError(exception)); 46 ASSERT(!Dart_IsError(exception));
54 Dart_ThrowException(exception); 47 Dart_ThrowException(exception);
55 UNREACHABLE(); 48 UNREACHABLE();
56 return; 49 return;
57 } 50 }
58 51
59 52
60 // List all native functions implemented in the vm or core boot strap dart 53 // List all native functions implemented in the vm or core boot strap dart
61 // libraries so that we can resolve the native function to it's entry 54 // libraries so that we can resolve the native function to it's entry
62 // point. 55 // point.
63 #define UNHANDLED_NATIVE_LIST(V) \ 56 #define UNHANDLED_NATIVE_LIST(V) \
64 V(Unhandled_equals, 2) \ 57 V(Unhandled_equals, 2) \
65 V(Unhandled_invoke, 0) \ 58 V(Unhandled_invoke, 0) \
66 V(Unhandled_invoke2, 0) \ 59 V(Unhandled_invoke2, 0)
67 60
68 61
69 static struct NativeEntries { 62 static struct NativeEntries {
70 const char* name_; 63 const char* name_;
71 Dart_NativeFunction function_; 64 Dart_NativeFunction function_;
72 int argument_count_; 65 int argument_count_;
73 } BuiltinEntries[] = { 66 } BuiltinEntries[] = {UNHANDLED_NATIVE_LIST(REGISTER_FUNCTION)};
74 UNHANDLED_NATIVE_LIST(REGISTER_FUNCTION)
75 };
76 67
77 68
78 static Dart_NativeFunction native_lookup(Dart_Handle name, 69 static Dart_NativeFunction native_lookup(Dart_Handle name,
79 int argument_count, 70 int argument_count,
80 bool* auto_setup_scope) { 71 bool* auto_setup_scope) {
81 ASSERT(auto_setup_scope != NULL); 72 ASSERT(auto_setup_scope != NULL);
82 *auto_setup_scope = true; 73 *auto_setup_scope = true;
83 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); 74 const Object& obj = Object::Handle(Api::UnwrapHandle(name));
84 ASSERT(obj.IsString()); 75 ASSERT(obj.IsString());
85 const char* function_name = obj.ToCString(); 76 const char* function_name = obj.ToCString();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 " return 3;\n" 111 " return 3;\n"
121 " }\n" 112 " }\n"
122 " return 2;\n" 113 " return 2;\n"
123 " }\n" 114 " }\n"
124 "}\n" 115 "}\n"
125 "testMain() {\n" 116 "testMain() {\n"
126 " UnhandledExceptions.equals(2, Second.method1(1));\n" 117 " UnhandledExceptions.equals(2, Second.method1(1));\n"
127 " UnhandledExceptions.equals(3, Second.method3(1));\n" 118 " UnhandledExceptions.equals(3, Second.method3(1));\n"
128 "}"; 119 "}";
129 Dart_Handle lib = TestCase::LoadTestScript( 120 Dart_Handle lib = TestCase::LoadTestScript(
130 kScriptChars, 121 kScriptChars, reinterpret_cast<Dart_NativeEntryResolver>(native_lookup));
131 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup));
132 EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, NULL)); 122 EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, NULL));
133 } 123 }
134 124
135 } // namespace dart 125 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/find_code_object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698