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 "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 Loading... | |
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 Map. | |
1399 result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); | |
1400 EXPECT_VALID(result); | |
1401 EXPECT(Dart_IsFuture(result)); | |
siva
2014/09/19 17:38:36
You probably also want a negative test:
Dart_Hand
rmacnak
2014/09/19 21:32:03
Added
| |
1402 } | |
1403 | |
1404 | |
1387 TEST_CASE(TypedDataViewListGetAsBytes) { | 1405 TEST_CASE(TypedDataViewListGetAsBytes) { |
1388 const int kSize = 1000; | 1406 const int kSize = 1000; |
1389 | 1407 |
1390 const char* kScriptChars = | 1408 const char* kScriptChars = |
1391 "import 'dart:typed_data';\n" | 1409 "import 'dart:typed_data';\n" |
1392 "List main(int size) {\n" | 1410 "List main(int size) {\n" |
1393 " var a = new Int8List(size);\n" | 1411 " var a = new Int8List(size);\n" |
1394 " var view = new Int8List.view(a.buffer, 0, size);\n" | 1412 " var view = new Int8List.view(a.buffer, 0, size);\n" |
1395 " return view;\n" | 1413 " return view;\n" |
1396 "}\n"; | 1414 "}\n"; |
(...skipping 7269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8666 NewString("main"), | 8684 NewString("main"), |
8667 1, | 8685 1, |
8668 dart_args); | 8686 dart_args); |
8669 int64_t value = 0; | 8687 int64_t value = 0; |
8670 result = Dart_IntegerToInt64(result, &value); | 8688 result = Dart_IntegerToInt64(result, &value); |
8671 EXPECT_VALID(result); | 8689 EXPECT_VALID(result); |
8672 EXPECT_EQ(6, value); | 8690 EXPECT_EQ(6, value); |
8673 } | 8691 } |
8674 | 8692 |
8675 } // namespace dart | 8693 } // namespace dart |
OLD | NEW |