Chromium Code Reviews| Index: runtime/vm/dart_api_impl_test.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl_test.cc (revision 653) |
| +++ runtime/vm/dart_api_impl_test.cc (working copy) |
| @@ -1298,6 +1298,58 @@ |
| } |
| +void NativeArgumentCounter(Dart_NativeArguments args) { |
| + Dart_EnterScope(); |
| + int count = Dart_GetNativeArgumentCount(args); |
| + Dart_SetReturnValue(args, Dart_NewInteger(count)); |
| + Dart_ExitScope(); |
| +} |
| + |
| + |
| +static Dart_NativeFunction gnac_lookup(Dart_Handle name, int argument_count) { |
| + return reinterpret_cast<Dart_NativeFunction>(&NativeArgumentCounter); |
| +} |
| + |
| + |
| +UNIT_TEST_CASE(GetNativeArgumentCount) { |
| + const char* kScriptChars = |
| + "class MyObject {\n" |
| + " int method1(int i, int j) native \"Name_Does_Not_Matter\";" |
|
siva
2011/10/24 22:58:43
The new style now seems to be use '
e.g: 'Name_Doe
turnidge
2011/10/24 23:44:19
Done.
|
| + "}\n" |
| + "class Test {\n" |
| + " static testMain() {\n" |
| + " MyObject obj = new MyObject();\n" |
| + " return obj.method1(77, 125);\n" |
| + " }\n" |
| + "}\n"; |
|
siva
2011/10/24 22:58:43
I believe in some of the newer tests we also remov
turnidge
2011/10/24 23:44:19
Done.
|
| + |
| + Dart_CreateIsolate(NULL, NULL); |
| + { |
| + Dart_EnterScope(); |
| + Dart_Handle lib = TestCase::LoadTestScript( |
| + kScriptChars, |
| + reinterpret_cast<Dart_NativeEntryResolver>(gnac_lookup)); |
| + |
| + Dart_Result result = Dart_InvokeStatic(lib, |
| + Dart_NewString("Test"), |
| + Dart_NewString("testMain"), |
| + 0, |
| + NULL); |
| + EXPECT(Dart_IsValidResult(result)); |
| + Dart_Handle result_obj = Dart_GetResult(result); |
| + EXPECT(Dart_IsInteger(result_obj)); |
| + |
| + result = Dart_IntegerValue(result_obj); |
| + EXPECT(Dart_IsValidResult(result)); |
| + int64_t value = Dart_GetResultAsCInt64(result); |
| + EXPECT_EQ(3, value); |
| + |
| + Dart_ExitScope(); |
| + } |
| + Dart_ShutdownIsolate(); |
| +} |
| + |
| + |
| UNIT_TEST_CASE(InstanceOf) { |
| const char* kScriptChars = |
| "class OtherClass {\n" |