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 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 | 2597 |
2598 | 2598 |
2599 UNIT_TEST_CASE(PostCObject) { | 2599 UNIT_TEST_CASE(PostCObject) { |
2600 // Create a native port for posting from C to Dart | 2600 // Create a native port for posting from C to Dart |
2601 TestIsolateScope __test_isolate__; | 2601 TestIsolateScope __test_isolate__; |
2602 const char* kScriptChars = | 2602 const char* kScriptChars = |
2603 "import 'dart:isolate';\n" | 2603 "import 'dart:isolate';\n" |
2604 "main() {\n" | 2604 "main() {\n" |
2605 " var messageCount = 0;\n" | 2605 " var messageCount = 0;\n" |
2606 " var exception = '';\n" | 2606 " var exception = '';\n" |
2607 " var port = new ReceivePort();\n" | 2607 " var port = new RawReceivePort();\n" |
2608 " port.receive((message, replyTo) {\n" | 2608 " port.handler = (message) {\n" |
2609 " if (messageCount < 8) {\n" | 2609 " if (messageCount < 8) {\n" |
2610 " exception = '$exception${message}';\n" | 2610 " exception = '$exception${message}';\n" |
2611 " } else {\n" | 2611 " } else {\n" |
2612 " exception = '$exception${message.length}';\n" | 2612 " exception = '$exception${message.length}';\n" |
2613 " for (int i = 0; i < message.length; i++) {\n" | 2613 " for (int i = 0; i < message.length; i++) {\n" |
2614 " exception = '$exception${message[i]}';\n" | 2614 " exception = '$exception${message[i]}';\n" |
2615 " }\n" | 2615 " }\n" |
2616 " }\n" | 2616 " }\n" |
2617 " messageCount++;\n" | 2617 " messageCount++;\n" |
2618 " if (messageCount == 9) throw new Exception(exception);\n" | 2618 " if (messageCount == 9) throw new Exception(exception);\n" |
2619 " });\n" | 2619 " };\n" |
2620 " return port.toSendPort();\n" | 2620 " return port.sendPort;\n" |
2621 "}\n"; | 2621 "}\n"; |
2622 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 2622 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
2623 Dart_EnterScope(); | 2623 Dart_EnterScope(); |
2624 | 2624 |
2625 Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2625 Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2626 EXPECT_VALID(send_port); | 2626 EXPECT_VALID(send_port); |
2627 Dart_Handle result = Dart_GetField(send_port, NewString("_id")); | 2627 Dart_Handle result = Dart_GetField(send_port, NewString("_id")); |
2628 ASSERT(!Dart_IsError(result)); | 2628 ASSERT(!Dart_IsError(result)); |
2629 ASSERT(Dart_IsInteger(result)); | 2629 ASSERT(Dart_IsInteger(result)); |
2630 int64_t send_port_id; | 2630 int64_t send_port_id; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 result = Dart_RunLoop(); | 2687 result = Dart_RunLoop(); |
2688 EXPECT(Dart_IsError(result)); | 2688 EXPECT(Dart_IsError(result)); |
2689 EXPECT(Dart_ErrorHasException(result)); | 2689 EXPECT(Dart_ErrorHasException(result)); |
2690 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2690 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
2691 Dart_GetError(result)); | 2691 Dart_GetError(result)); |
2692 | 2692 |
2693 Dart_ExitScope(); | 2693 Dart_ExitScope(); |
2694 } | 2694 } |
2695 | 2695 |
2696 } // namespace dart | 2696 } // namespace dart |
OLD | NEW |