| OLD | NEW |
| 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 "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 3343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3354 result = Dart_New(cls, Dart_NewString("named"), -1, args); | 3354 result = Dart_New(cls, Dart_NewString("named"), -1, args); |
| 3355 EXPECT_ERROR( | 3355 EXPECT_ERROR( |
| 3356 result, | 3356 result, |
| 3357 "Dart_New expects argument 'number_of_arguments' to be non-negative."); | 3357 "Dart_New expects argument 'number_of_arguments' to be non-negative."); |
| 3358 | 3358 |
| 3359 // Pass the wrong arg count. | 3359 // Pass the wrong arg count. |
| 3360 result = Dart_New(cls, Dart_NewString("named"), 0, NULL); | 3360 result = Dart_New(cls, Dart_NewString("named"), 0, NULL); |
| 3361 EXPECT_ERROR( | 3361 EXPECT_ERROR( |
| 3362 result, | 3362 result, |
| 3363 "Dart_New: wrong argument count for constructor 'MyClass.named': " | 3363 "Dart_New: wrong argument count for constructor 'MyClass.named': " |
| 3364 "expected 1 but saw 0."); | 3364 "0 passed, 1 expected."); |
| 3365 | 3365 |
| 3366 // Pass a bad argument. Error is passed through. | 3366 // Pass a bad argument. Error is passed through. |
| 3367 result = Dart_New(cls, Dart_NewString("named"), 1, bad_args); | 3367 result = Dart_New(cls, Dart_NewString("named"), 1, bad_args); |
| 3368 EXPECT_ERROR(result, "myerror"); | 3368 EXPECT_ERROR(result, "myerror"); |
| 3369 | 3369 |
| 3370 // Pass a bad constructor name. | 3370 // Pass a bad constructor name. |
| 3371 result = Dart_New(cls, Dart_NewInteger(55), 1, args); | 3371 result = Dart_New(cls, Dart_NewInteger(55), 1, args); |
| 3372 EXPECT_ERROR( | 3372 EXPECT_ERROR( |
| 3373 result, | 3373 result, |
| 3374 "Dart_New expects argument 'constructor_name' to be of type String."); | 3374 "Dart_New expects argument 'constructor_name' to be of type String."); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3582 name = Dart_NewString("topMethod"); | 3582 name = Dart_NewString("topMethod"); |
| 3583 EXPECT(Dart_IsError(Dart_Invoke(cls, name, 1, args))); | 3583 EXPECT(Dart_IsError(Dart_Invoke(cls, name, 1, args))); |
| 3584 EXPECT(Dart_IsError(Dart_Invoke(instance, name, 1, args))); | 3584 EXPECT(Dart_IsError(Dart_Invoke(instance, name, 1, args))); |
| 3585 result = Dart_Invoke(lib, name, 1, args); | 3585 result = Dart_Invoke(lib, name, 1, args); |
| 3586 EXPECT_VALID(result); | 3586 EXPECT_VALID(result); |
| 3587 result = Dart_StringToCString(result, &str); | 3587 result = Dart_StringToCString(result, &str); |
| 3588 EXPECT_STREQ("top !!!", str); | 3588 EXPECT_STREQ("top !!!", str); |
| 3589 | 3589 |
| 3590 // Top-level method, wrong arg count. | 3590 // Top-level method, wrong arg count. |
| 3591 EXPECT_ERROR(Dart_Invoke(lib, name, 2, bad_args), | 3591 EXPECT_ERROR(Dart_Invoke(lib, name, 2, bad_args), |
| 3592 "did not find top-level function 'topMethod'"); | 3592 "Dart_Invoke: wrong argument count for function 'topMethod': " |
| 3593 "2 passed, 1 expected."); |
| 3593 | 3594 |
| 3594 // Hidden top-level method. | 3595 // Hidden top-level method. |
| 3595 name = Dart_NewString("_topMethod"); | 3596 name = Dart_NewString("_topMethod"); |
| 3596 EXPECT(Dart_IsError(Dart_Invoke(cls, name, 1, args))); | 3597 EXPECT(Dart_IsError(Dart_Invoke(cls, name, 1, args))); |
| 3597 EXPECT(Dart_IsError(Dart_Invoke(instance, name, 1, args))); | 3598 EXPECT(Dart_IsError(Dart_Invoke(instance, name, 1, args))); |
| 3598 result = Dart_Invoke(lib, name, 1, args); | 3599 result = Dart_Invoke(lib, name, 1, args); |
| 3599 EXPECT_VALID(result); | 3600 EXPECT_VALID(result); |
| 3600 result = Dart_StringToCString(result, &str); | 3601 result = Dart_StringToCString(result, &str); |
| 3601 EXPECT_STREQ("hidden top !!!", str); | 3602 EXPECT_STREQ("hidden top !!!", str); |
| 3602 } | 3603 } |
| (...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6159 EXPECT_VALID(result); | 6160 EXPECT_VALID(result); |
| 6160 EXPECT(Dart_IsInteger(result)); | 6161 EXPECT(Dart_IsInteger(result)); |
| 6161 int64_t value = 0; | 6162 int64_t value = 0; |
| 6162 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); | 6163 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 6163 EXPECT_EQ(0, value); | 6164 EXPECT_EQ(0, value); |
| 6164 } | 6165 } |
| 6165 | 6166 |
| 6166 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 6167 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 6167 | 6168 |
| 6168 } // namespace dart | 6169 } // namespace dart |
| OLD | NEW |