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

Side by Side Diff: runtime/vm/snapshot_test.cc

Issue 9372024: Add missing backref collection when reading mint and bigint objects in a native message handler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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_message.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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_message.h" 10 #include "vm/dart_api_message.h"
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { 1298 UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
1299 const int kArrayLength = 10; 1299 const int kArrayLength = 10;
1300 static const char* kScriptChars = 1300 static const char* kScriptChars =
1301 "final int kArrayLength = 10;\n" 1301 "final int kArrayLength = 10;\n"
1302 "getStringList() {\n" 1302 "getStringList() {\n"
1303 " var s = 'Hello, world!';\n" 1303 " var s = 'Hello, world!';\n"
1304 " var list = new List<String>(kArrayLength);\n" 1304 " var list = new List<String>(kArrayLength);\n"
1305 " for (var i = 0; i < kArrayLength; i++) list[i] = s;\n" 1305 " for (var i = 0; i < kArrayLength; i++) list[i] = s;\n"
1306 " return list;\n" 1306 " return list;\n"
1307 "}\n" 1307 "}\n"
1308 "getMintList() {\n"
1309 " var mint = 0x7FFFFFFFFFFFFFFF;\n"
1310 " var list = new List(kArrayLength);\n"
1311 " for (var i = 0; i < kArrayLength; i++) list[i] = mint;\n"
1312 " return list;\n"
1313 "}\n"
1314 "getBigintList() {\n"
1315 " var bigint = 0x1234567890123456789012345678901234567890;\n"
1316 " var list = new List(kArrayLength);\n"
1317 " for (var i = 0; i < kArrayLength; i++) list[i] = bigint;\n"
1318 " return list;\n"
1319 "}\n"
1308 "getDoubleList() {\n" 1320 "getDoubleList() {\n"
1309 " var d = 3.14;\n" 1321 " var d = 3.14;\n"
1310 " var list = new List<double>(kArrayLength);\n" 1322 " var list = new List<double>(kArrayLength);\n"
1311 " for (var i = 0; i < kArrayLength; i++) list[i] = d;\n" 1323 " for (var i = 0; i < kArrayLength; i++) list[i] = d;\n"
1312 " return list;\n" 1324 " return list;\n"
1313 "}\n" 1325 "}\n"
1314 "getByteArrayList() {\n" 1326 "getByteArrayList() {\n"
1315 " var byte_array = new ByteArray(256);\n" 1327 " var byte_array = new ByteArray(256);\n"
1316 " var list = new List<ByteArray>(kArrayLength);\n" 1328 " var list = new List<ByteArray>(kArrayLength);\n"
1317 " for (var i = 0; i < kArrayLength; i++) list[i] = byte_array;\n" 1329 " for (var i = 0; i < kArrayLength; i++) list[i] = byte_array;\n"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 EXPECT_EQ(Dart_CObject::kArray, root->type); 1363 EXPECT_EQ(Dart_CObject::kArray, root->type);
1352 EXPECT_EQ(kArrayLength, root->value.as_array.length); 1364 EXPECT_EQ(kArrayLength, root->value.as_array.length);
1353 for (int i = 0; i < kArrayLength; i++) { 1365 for (int i = 0; i < kArrayLength; i++) {
1354 Dart_CObject* element = root->value.as_array.values[i]; 1366 Dart_CObject* element = root->value.as_array.values[i];
1355 EXPECT_EQ(root->value.as_array.values[0], element); 1367 EXPECT_EQ(root->value.as_array.values[0], element);
1356 EXPECT_EQ(Dart_CObject::kString, element->type); 1368 EXPECT_EQ(Dart_CObject::kString, element->type);
1357 EXPECT_STREQ("Hello, world!", element->value.as_string); 1369 EXPECT_STREQ("Hello, world!", element->value.as_string);
1358 } 1370 }
1359 } 1371 }
1360 { 1372 {
1373 // Generate a list of medium ints from Dart code.
1374 ApiNativeScope scope;
1375 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMintList");
1376 EXPECT_NOTNULL(root);
1377 EXPECT_EQ(Dart_CObject::kArray, root->type);
1378 EXPECT_EQ(kArrayLength, root->value.as_array.length);
1379 for (int i = 0; i < kArrayLength; i++) {
1380 Dart_CObject* element = root->value.as_array.values[i];
1381 EXPECT_EQ(root->value.as_array.values[0], element);
1382 EXPECT_EQ(Dart_CObject::kInt64, element->type);
1383 }
1384 }
1385 {
1386 // Generate a list of bigints from Dart code.
1387 ApiNativeScope scope;
1388 Dart_CObject* root = GetDeserializedDartMessage(lib, "getBigintList");
1389 EXPECT_NOTNULL(root);
1390 EXPECT_EQ(Dart_CObject::kArray, root->type);
1391 EXPECT_EQ(kArrayLength, root->value.as_array.length);
1392 for (int i = 0; i < kArrayLength; i++) {
1393 Dart_CObject* element = root->value.as_array.values[i];
1394 EXPECT_EQ(root->value.as_array.values[0], element);
1395 EXPECT_EQ(Dart_CObject::kBigint, element->type);
1396 }
1397 }
1398 {
1361 // Generate a list of doubles from Dart code. 1399 // Generate a list of doubles from Dart code.
1362 ApiNativeScope scope; 1400 ApiNativeScope scope;
1363 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); 1401 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList");
1364 EXPECT_NOTNULL(root); 1402 EXPECT_NOTNULL(root);
1365 EXPECT_EQ(Dart_CObject::kArray, root->type); 1403 EXPECT_EQ(Dart_CObject::kArray, root->type);
1366 EXPECT_EQ(kArrayLength, root->value.as_array.length); 1404 EXPECT_EQ(kArrayLength, root->value.as_array.length);
1367 for (int i = 0; i < kArrayLength; i++) { 1405 for (int i = 0; i < kArrayLength; i++) {
1368 Dart_CObject* element = root->value.as_array.values[i]; 1406 Dart_CObject* element = root->value.as_array.values[i];
1369 EXPECT_EQ(root->value.as_array.values[0], element); 1407 EXPECT_EQ(root->value.as_array.values[0], element);
1370 EXPECT_EQ(Dart_CObject::kDouble, element->type); 1408 EXPECT_EQ(Dart_CObject::kDouble, element->type);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 EXPECT(Dart_ErrorHasException(result)); 1530 EXPECT(Dart_ErrorHasException(result));
1493 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]\n", 1531 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]\n",
1494 Dart_GetError(result)); 1532 Dart_GetError(result));
1495 1533
1496 Dart_ExitScope(); 1534 Dart_ExitScope();
1497 } 1535 }
1498 1536
1499 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 1537 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
1500 1538
1501 } // namespace dart 1539 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698