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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 585643004: Add Dart_IsFuture. To be used in Dartium implementation of Promises. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 4b0b5d51fccaf47a031352c86564b57888497486..ec4070e5376eed8b28e1771d7e7c6643069b1255 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1384,6 +1384,32 @@ TEST_CASE(MapAccess) {
}
+TEST_CASE(IsFuture) {
+ const char* kScriptChars =
+ "import 'dart:async';"
+ "Future testMain() {"
+ " return new Completer().future;"
+ "}";
+ Dart_Handle result;
+
+ // Create a test library and Load up a test script in it.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ // Invoke a function which returns an object of type Future.
+ result = Dart_Invoke(lib, NewString("testMain"), 0, NULL);
+ EXPECT_VALID(result);
+ EXPECT(Dart_IsFuture(result));
+
+ EXPECT(!Dart_IsFuture(lib)); // Non-instance.
+ Dart_Handle anInteger = Dart_NewInteger(0);
+ EXPECT(!Dart_IsFuture(anInteger));
+ Dart_Handle aString = NewString("I am not a Future");
+ EXPECT(!Dart_IsFuture(aString));
+ Dart_Handle null = Dart_Null();
+ EXPECT(!Dart_IsFuture(null));
+}
+
+
TEST_CASE(TypedDataViewListGetAsBytes) {
const int kSize = 1000;
« 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