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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 8382017: Add Dart_GetNativeArgumentCount() and a test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698