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 "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 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 | 2572 |
2573 | 2573 |
2574 UNIT_TEST_CASE(PostCObject) { | 2574 UNIT_TEST_CASE(PostCObject) { |
2575 // Create a native port for posting from C to Dart | 2575 // Create a native port for posting from C to Dart |
2576 TestIsolateScope __test_isolate__; | 2576 TestIsolateScope __test_isolate__; |
2577 const char* kScriptChars = | 2577 const char* kScriptChars = |
2578 "import 'dart:isolate';\n" | 2578 "import 'dart:isolate';\n" |
2579 "main() {\n" | 2579 "main() {\n" |
2580 " var messageCount = 0;\n" | 2580 " var messageCount = 0;\n" |
2581 " var exception = '';\n" | 2581 " var exception = '';\n" |
2582 " var port = new ReceivePort();\n" | 2582 " var port = new RawReceivePort();\n" |
2583 " port.receive((message, replyTo) {\n" | 2583 " port.handler = (message) {\n" |
2584 " if (messageCount < 8) {\n" | 2584 " if (messageCount < 8) {\n" |
2585 " exception = '$exception${message}';\n" | 2585 " exception = '$exception${message}';\n" |
2586 " } else {\n" | 2586 " } else {\n" |
2587 " exception = '$exception${message.length}';\n" | 2587 " exception = '$exception${message.length}';\n" |
2588 " for (int i = 0; i < message.length; i++) {\n" | 2588 " for (int i = 0; i < message.length; i++) {\n" |
2589 " exception = '$exception${message[i]}';\n" | 2589 " exception = '$exception${message[i]}';\n" |
2590 " }\n" | 2590 " }\n" |
2591 " }\n" | 2591 " }\n" |
2592 " messageCount++;\n" | 2592 " messageCount++;\n" |
2593 " if (messageCount == 9) throw new Exception(exception);\n" | 2593 " if (messageCount == 9) throw new Exception(exception);\n" |
2594 " });\n" | 2594 " };\n" |
2595 " return port.toSendPort();\n" | 2595 " return port.sendPort;\n" |
2596 "}\n"; | 2596 "}\n"; |
2597 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 2597 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
2598 Dart_EnterScope(); | 2598 Dart_EnterScope(); |
2599 | 2599 |
2600 Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2600 Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2601 EXPECT_VALID(send_port); | 2601 EXPECT_VALID(send_port); |
2602 Dart_Handle result = Dart_GetField(send_port, NewString("_id")); | 2602 Dart_Handle result = Dart_GetField(send_port, NewString("_id")); |
2603 ASSERT(!Dart_IsError(result)); | 2603 ASSERT(!Dart_IsError(result)); |
2604 ASSERT(Dart_IsInteger(result)); | 2604 ASSERT(Dart_IsInteger(result)); |
2605 int64_t send_port_id; | 2605 int64_t send_port_id; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 result = Dart_RunLoop(); | 2662 result = Dart_RunLoop(); |
2663 EXPECT(Dart_IsError(result)); | 2663 EXPECT(Dart_IsError(result)); |
2664 EXPECT(Dart_ErrorHasException(result)); | 2664 EXPECT(Dart_ErrorHasException(result)); |
2665 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2665 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
2666 Dart_GetError(result)); | 2666 Dart_GetError(result)); |
2667 | 2667 |
2668 Dart_ExitScope(); | 2668 Dart_ExitScope(); |
2669 } | 2669 } |
2670 | 2670 |
2671 } // namespace dart | 2671 } // namespace dart |
OLD | NEW |