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

Unified Diff: runtime/vm/snapshot_test.cc

Issue 9347040: Add API function Dart_ZoneAllocate (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from iposva@ 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot_test.cc
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index ecde1ca7ff961159e42cdb3e811734ae058502ba..2452b98c66b3793198f31a144d34f7cc64521951 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -1473,9 +1473,16 @@ UNIT_TEST_CASE(PostCObject) {
" var exception = '';\n"
" var port = new ReceivePort();\n"
" port.receive((message, replyTo) {\n"
- " exception += message.toString();\n"
+ " if (messageCount < 7) {\n"
+ " exception += message.toString();\n"
+ " } else {\n"
+ " exception += message.length;\n"
+ " for (int i = 0; i < message.length; i++) {\n"
+ " exception += message[i];\n"
+ " }\n"
+ " }\n"
" messageCount++;\n"
- " if (messageCount == 7) throw new Exception(exception);\n"
+ " if (messageCount == 8) throw new Exception(exception);\n"
" });\n"
" return port.toSendPort();\n"
"}\n";
@@ -1527,10 +1534,29 @@ UNIT_TEST_CASE(PostCObject) {
object.value.as_array.length = 0;
EXPECT(Dart_PostCObject(send_port_id, &object));
+ static const int kArrayLength = 10;
+ Dart_CObject* array =
+ reinterpret_cast<Dart_CObject*>(
+ Dart_ZoneAllocate(
+ sizeof(Dart_CObject) + sizeof(Dart_CObject*) * kArrayLength)); // NOLINT
+ array->type = Dart_CObject::Dart_CObject::kArray;
+ array->value.as_array.length = kArrayLength;
+ array->value.as_array.values =
+ reinterpret_cast<Dart_CObject**>(array + 1);
+ for (int i = 0; i < kArrayLength; i++) {
+ Dart_CObject* element =
+ reinterpret_cast<Dart_CObject*>(
+ Dart_ZoneAllocate(sizeof(Dart_CObject)));
+ element->type = Dart_CObject::kInt32;
+ element->value.as_int32 = i;
+ array->value.as_array.values[i] = element;
+ }
+ EXPECT(Dart_PostCObject(send_port_id, array));
+
result = Dart_RunLoop();
EXPECT(Dart_IsError(result));
EXPECT(Dart_ErrorHasException(result));
- EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]\n",
+ EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n",
Dart_GetError(result));
Dart_ExitScope();
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698