| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 TestCase::url()); | 1215 TestCase::url()); |
| 1216 EXPECT_STREQ(Dart_GetError(expected_error), Dart_GetError(result)); | 1216 EXPECT_STREQ(Dart_GetError(expected_error), Dart_GetError(result)); |
| 1217 } | 1217 } |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 | 1220 |
| 1221 static void TestNativeFields(Dart_Handle retobj) { | 1221 static void TestNativeFields(Dart_Handle retobj) { |
| 1222 // Access and set various instance fields of the object. | 1222 // Access and set various instance fields of the object. |
| 1223 Dart_Handle result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); | 1223 Dart_Handle result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); |
| 1224 EXPECT(Dart_IsError(result)); | 1224 EXPECT(Dart_IsError(result)); |
| 1225 result = Dart_GetInstanceField(retobj, Dart_NewString("fld0")); |
| 1226 EXPECT_VALID(result); |
| 1227 EXPECT(Dart_IsNull(result)); |
| 1225 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 1228 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 1226 EXPECT_VALID(result); | 1229 EXPECT_VALID(result); |
| 1227 int64_t value = 0; | 1230 int64_t value = 0; |
| 1228 result = Dart_IntegerValue(result, &value); | 1231 result = Dart_IntegerValue(result, &value); |
| 1229 EXPECT_EQ(10, value); | 1232 EXPECT_EQ(10, value); |
| 1230 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); | 1233 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); |
| 1231 EXPECT_VALID(result); | 1234 EXPECT_VALID(result); |
| 1232 result = Dart_IntegerValue(result, &value); | 1235 result = Dart_IntegerValue(result, &value); |
| 1233 EXPECT_EQ(20, value); | 1236 EXPECT_EQ(20, value); |
| 1234 result = Dart_SetInstanceField(retobj, | 1237 result = Dart_SetInstanceField(retobj, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1255 EXPECT(Dart_IsError(result)); | 1258 EXPECT(Dart_IsError(result)); |
| 1256 result = Dart_GetNativeInstanceField(retobj, kNativeFld0, &field_value); | 1259 result = Dart_GetNativeInstanceField(retobj, kNativeFld0, &field_value); |
| 1257 EXPECT_VALID(result); | 1260 EXPECT_VALID(result); |
| 1258 EXPECT_EQ(0, field_value); | 1261 EXPECT_EQ(0, field_value); |
| 1259 result = Dart_GetNativeInstanceField(retobj, kNativeFld1, &field_value); | 1262 result = Dart_GetNativeInstanceField(retobj, kNativeFld1, &field_value); |
| 1260 EXPECT_VALID(result); | 1263 EXPECT_VALID(result); |
| 1261 EXPECT_EQ(0, field_value); | 1264 EXPECT_EQ(0, field_value); |
| 1262 result = Dart_GetNativeInstanceField(retobj, kNativeFld2, &field_value); | 1265 result = Dart_GetNativeInstanceField(retobj, kNativeFld2, &field_value); |
| 1263 EXPECT_VALID(result); | 1266 EXPECT_VALID(result); |
| 1264 EXPECT_EQ(0, field_value); | 1267 EXPECT_EQ(0, field_value); |
| 1268 result = Dart_GetNativeInstanceField(retobj, kNativeFld3, &field_value); |
| 1269 EXPECT_VALID(result); |
| 1270 EXPECT_EQ(0, field_value); |
| 1265 result = Dart_SetNativeInstanceField(retobj, kNativeFld4, 40); | 1271 result = Dart_SetNativeInstanceField(retobj, kNativeFld4, 40); |
| 1266 EXPECT(Dart_IsError(result)); | 1272 EXPECT(Dart_IsError(result)); |
| 1267 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 4); | 1273 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 4); |
| 1268 EXPECT_VALID(result); | 1274 EXPECT_VALID(result); |
| 1269 result = Dart_SetNativeInstanceField(retobj, kNativeFld1, 40); | 1275 result = Dart_SetNativeInstanceField(retobj, kNativeFld1, 40); |
| 1270 EXPECT_VALID(result); | 1276 EXPECT_VALID(result); |
| 1271 result = Dart_SetNativeInstanceField(retobj, kNativeFld2, 400); | 1277 result = Dart_SetNativeInstanceField(retobj, kNativeFld2, 400); |
| 1272 EXPECT_VALID(result); | 1278 EXPECT_VALID(result); |
| 1273 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 4000); | 1279 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 4000); |
| 1274 EXPECT_VALID(result); | 1280 EXPECT_VALID(result); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1286 EXPECT_VALID(result); | 1292 EXPECT_VALID(result); |
| 1287 result = Dart_IntegerValue(result, &value); | 1293 result = Dart_IntegerValue(result, &value); |
| 1288 EXPECT_EQ(20, value); | 1294 EXPECT_EQ(20, value); |
| 1289 } | 1295 } |
| 1290 | 1296 |
| 1291 | 1297 |
| 1292 UNIT_TEST_CASE(NativeFieldAccess) { | 1298 UNIT_TEST_CASE(NativeFieldAccess) { |
| 1293 const char* kScriptChars = | 1299 const char* kScriptChars = |
| 1294 "class NativeFields extends NativeFieldsWrapper {\n" | 1300 "class NativeFields extends NativeFieldsWrapper {\n" |
| 1295 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1301 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 1302 " int fld0;\n" |
| 1296 " int fld1;\n" | 1303 " int fld1;\n" |
| 1297 " final int fld2;\n" | 1304 " final int fld2;\n" |
| 1298 " static int fld3;\n" | 1305 " static int fld3;\n" |
| 1299 " static final int fld4 = 10;\n" | 1306 " static final int fld4 = 10;\n" |
| 1300 "}\n" | 1307 "}\n" |
| 1301 "class NativeFieldsTest {\n" | 1308 "class NativeFieldsTest {\n" |
| 1302 " static NativeFields testMain() {\n" | 1309 " static NativeFields testMain() {\n" |
| 1303 " NativeFields obj = new NativeFields(10, 20);\n" | 1310 " NativeFields obj = new NativeFields(10, 20);\n" |
| 1304 " return obj;\n" | 1311 " return obj;\n" |
| 1305 " }\n" | 1312 " }\n" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1334 TestNativeFields(retobj); | 1341 TestNativeFields(retobj); |
| 1335 } | 1342 } |
| 1336 } | 1343 } |
| 1337 | 1344 |
| 1338 | 1345 |
| 1339 UNIT_TEST_CASE(ImplicitNativeFieldAccess) { | 1346 UNIT_TEST_CASE(ImplicitNativeFieldAccess) { |
| 1340 const char* kScriptChars = | 1347 const char* kScriptChars = |
| 1341 "#import('dart:nativewrappers');" | 1348 "#import('dart:nativewrappers');" |
| 1342 "class NativeFields extends NativeFieldWrapperClass4 {\n" | 1349 "class NativeFields extends NativeFieldWrapperClass4 {\n" |
| 1343 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1350 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 1351 " int fld0;\n" |
| 1344 " int fld1;\n" | 1352 " int fld1;\n" |
| 1345 " final int fld2;\n" | 1353 " final int fld2;\n" |
| 1346 " static int fld3;\n" | 1354 " static int fld3;\n" |
| 1347 " static final int fld4 = 10;\n" | 1355 " static final int fld4 = 10;\n" |
| 1348 "}\n" | 1356 "}\n" |
| 1349 "class NativeFieldsTest {\n" | 1357 "class NativeFieldsTest {\n" |
| 1350 " static NativeFields testMain() {\n" | 1358 " static NativeFields testMain() {\n" |
| 1351 " NativeFields obj = new NativeFields(10, 20);\n" | 1359 " NativeFields obj = new NativeFields(10, 20);\n" |
| 1352 " return obj;\n" | 1360 " return obj;\n" |
| 1353 " }\n" | 1361 " }\n" |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 } | 2764 } |
| 2757 | 2765 |
| 2758 | 2766 |
| 2759 UNIT_TEST_CASE(RunLoop_Exception) { | 2767 UNIT_TEST_CASE(RunLoop_Exception) { |
| 2760 RunLoopTest(true); | 2768 RunLoopTest(true); |
| 2761 } | 2769 } |
| 2762 | 2770 |
| 2763 #endif // TARGET_ARCH_IA32. | 2771 #endif // TARGET_ARCH_IA32. |
| 2764 | 2772 |
| 2765 } // namespace dart | 2773 } // namespace dart |
| OLD | NEW |