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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | 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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 result = Dart_ListGetAt(keys, 1); 1377 result = Dart_ListGetAt(keys, 1);
1378 EXPECT(Dart_IsString(result)); 1378 EXPECT(Dart_IsString(result));
1379 equals = false; 1379 equals = false;
1380 EXPECT_VALID(Dart_ObjectEquals(result, b, &equals)); 1380 EXPECT_VALID(Dart_ObjectEquals(result, b, &equals));
1381 EXPECT(equals); 1381 EXPECT(equals);
1382 1382
1383 EXPECT(Dart_IsError(Dart_MapKeys(a))); 1383 EXPECT(Dart_IsError(Dart_MapKeys(a)));
1384 } 1384 }
1385 1385
1386 1386
1387 TEST_CASE(IsFuture) {
1388 const char* kScriptChars =
1389 "import 'dart:async';"
1390 "Future testMain() {"
1391 " return new Completer().future;"
1392 "}";
1393 Dart_Handle result;
1394
1395 // Create a test library and Load up a test script in it.
1396 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1397
1398 // Invoke a function which returns an object of type Future.
1399 result = Dart_Invoke(lib, NewString("testMain"), 0, NULL);
1400 EXPECT_VALID(result);
1401 EXPECT(Dart_IsFuture(result));
1402
1403 EXPECT(!Dart_IsFuture(lib)); // Non-instance.
1404 Dart_Handle anInteger = Dart_NewInteger(0);
1405 EXPECT(!Dart_IsFuture(anInteger));
1406 Dart_Handle aString = NewString("I am not a Future");
1407 EXPECT(!Dart_IsFuture(aString));
1408 Dart_Handle null = Dart_Null();
1409 EXPECT(!Dart_IsFuture(null));
1410 }
1411
1412
1387 TEST_CASE(TypedDataViewListGetAsBytes) { 1413 TEST_CASE(TypedDataViewListGetAsBytes) {
1388 const int kSize = 1000; 1414 const int kSize = 1000;
1389 1415
1390 const char* kScriptChars = 1416 const char* kScriptChars =
1391 "import 'dart:typed_data';\n" 1417 "import 'dart:typed_data';\n"
1392 "List main(int size) {\n" 1418 "List main(int size) {\n"
1393 " var a = new Int8List(size);\n" 1419 " var a = new Int8List(size);\n"
1394 " var view = new Int8List.view(a.buffer, 0, size);\n" 1420 " var view = new Int8List.view(a.buffer, 0, size);\n"
1395 " return view;\n" 1421 " return view;\n"
1396 "}\n"; 1422 "}\n";
(...skipping 7269 matching lines...) Expand 10 before | Expand all | Expand 10 after
8666 NewString("main"), 8692 NewString("main"),
8667 1, 8693 1,
8668 dart_args); 8694 dart_args);
8669 int64_t value = 0; 8695 int64_t value = 0;
8670 result = Dart_IntegerToInt64(result, &value); 8696 result = Dart_IntegerToInt64(result, &value);
8671 EXPECT_VALID(result); 8697 EXPECT_VALID(result);
8672 EXPECT_EQ(6, value); 8698 EXPECT_EQ(6, value);
8673 } 8699 }
8674 8700
8675 } // namespace dart 8701 } // namespace dart
OLDNEW
« 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