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 "vm/compiler.h" | 6 #include "vm/compiler.h" |
7 #include "include/dart_api.h" | 7 #include "include/dart_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 "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-1"); | 1000 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-1"); |
1001 EXPECT(Dart_IsInteger(below_min)); | 1001 EXPECT(Dart_IsInteger(below_min)); |
1002 fits = true; | 1002 fits = true; |
1003 result = Dart_IntegerFitsIntoUint64(below_min, &fits); | 1003 result = Dart_IntegerFitsIntoUint64(below_min, &fits); |
1004 EXPECT_VALID(result); | 1004 EXPECT_VALID(result); |
1005 EXPECT(!fits); | 1005 EXPECT(!fits); |
1006 } | 1006 } |
1007 | 1007 |
1008 | 1008 |
1009 TEST_CASE(ArrayValues) { | 1009 TEST_CASE(ArrayValues) { |
| 1010 EXPECT(!Dart_IsList(Dart_Null())); |
1010 const int kArrayLength = 10; | 1011 const int kArrayLength = 10; |
1011 Dart_Handle str = NewString("test"); | 1012 Dart_Handle str = NewString("test"); |
1012 EXPECT(!Dart_IsList(str)); | 1013 EXPECT(!Dart_IsList(str)); |
1013 Dart_Handle val = Dart_NewList(kArrayLength); | 1014 Dart_Handle val = Dart_NewList(kArrayLength); |
1014 EXPECT(Dart_IsList(val)); | 1015 EXPECT(Dart_IsList(val)); |
1015 intptr_t len = 0; | 1016 intptr_t len = 0; |
1016 Dart_Handle result = Dart_ListLength(val, &len); | 1017 Dart_Handle result = Dart_ListLength(val, &len); |
1017 EXPECT_VALID(result); | 1018 EXPECT_VALID(result); |
1018 EXPECT_EQ(kArrayLength, len); | 1019 EXPECT_EQ(kArrayLength, len); |
1019 | 1020 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 EXPECT(Dart_IsError(result)); | 1467 EXPECT(Dart_IsError(result)); |
1467 EXPECT(Dart_IsUnhandledExceptionError(result)); | 1468 EXPECT(Dart_IsUnhandledExceptionError(result)); |
1468 | 1469 |
1469 result = Dart_ListSetAt(list_access_test_obj, 0, Dart_NewInteger(42)); | 1470 result = Dart_ListSetAt(list_access_test_obj, 0, Dart_NewInteger(42)); |
1470 EXPECT(Dart_IsError(result)); | 1471 EXPECT(Dart_IsError(result)); |
1471 EXPECT(Dart_IsUnhandledExceptionError(result)); | 1472 EXPECT(Dart_IsUnhandledExceptionError(result)); |
1472 } | 1473 } |
1473 | 1474 |
1474 | 1475 |
1475 TEST_CASE(MapAccess) { | 1476 TEST_CASE(MapAccess) { |
| 1477 EXPECT(!Dart_IsMap(Dart_Null())); |
1476 const char* kScriptChars = | 1478 const char* kScriptChars = |
1477 "Map testMain() {" | 1479 "Map testMain() {" |
1478 " return {" | 1480 " return {" |
1479 " 'a' : 1," | 1481 " 'a' : 1," |
1480 " 'b' : null," | 1482 " 'b' : null," |
1481 " };" | 1483 " };" |
1482 "}"; | 1484 "}"; |
1483 Dart_Handle result; | 1485 Dart_Handle result; |
1484 | 1486 |
1485 // Create a test library and Load up a test script in it. | 1487 // Create a test library and Load up a test script in it. |
(...skipping 8421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9907 EXPECT_VALID(result); | 9909 EXPECT_VALID(result); |
9908 result = Dart_FinalizeLoading(false); | 9910 result = Dart_FinalizeLoading(false); |
9909 EXPECT_VALID(result); | 9911 EXPECT_VALID(result); |
9910 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); | 9912 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); |
9911 EXPECT(Dart_IsError(result)); | 9913 EXPECT(Dart_IsError(result)); |
9912 } | 9914 } |
9913 | 9915 |
9914 #endif // !PRODUCT | 9916 #endif // !PRODUCT |
9915 | 9917 |
9916 } // namespace dart | 9918 } // namespace dart |
OLD | NEW |