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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 " exception = '$exception${message}';\n" | 2636 " exception = '$exception${message}';\n" |
2637 " } else {\n" | 2637 " } else {\n" |
2638 " exception = '$exception${message.length}';\n" | 2638 " exception = '$exception${message.length}';\n" |
2639 " for (int i = 0; i < message.length; i++) {\n" | 2639 " for (int i = 0; i < message.length; i++) {\n" |
2640 " exception = '$exception${message[i]}';\n" | 2640 " exception = '$exception${message[i]}';\n" |
2641 " }\n" | 2641 " }\n" |
2642 " }\n" | 2642 " }\n" |
2643 " messageCount++;\n" | 2643 " messageCount++;\n" |
2644 " if (messageCount == 9) throw new Exception(exception);\n" | 2644 " if (messageCount == 9) throw new Exception(exception);\n" |
2645 " };\n" | 2645 " };\n" |
2646 " return port.sendPort;\n" | 2646 " return port;\n" |
2647 "}\n"; | 2647 "}\n"; |
2648 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 2648 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
2649 Dart_EnterScope(); | 2649 Dart_EnterScope(); |
2650 | 2650 |
2651 Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2651 Dart_Handle recv_port = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2652 EXPECT_VALID(send_port); | 2652 EXPECT_VALID(recv_port); |
2653 Dart_Handle result = Dart_GetField(send_port, NewString("_id")); | 2653 Dart_Port port_id; |
| 2654 Dart_Handle result = Dart_ReceivePortGetId(recv_port, &port_id); |
2654 ASSERT(!Dart_IsError(result)); | 2655 ASSERT(!Dart_IsError(result)); |
2655 ASSERT(Dart_IsInteger(result)); | |
2656 int64_t send_port_id; | |
2657 Dart_Handle result2 = Dart_IntegerToInt64(result, &send_port_id); | |
2658 ASSERT(!Dart_IsError(result2)); | |
2659 | 2656 |
2660 // Setup single object message. | 2657 // Setup single object message. |
2661 Dart_CObject object; | 2658 Dart_CObject object; |
2662 | 2659 |
2663 object.type = Dart_CObject_kNull; | 2660 object.type = Dart_CObject_kNull; |
2664 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2661 EXPECT(Dart_PostCObject(port_id, &object)); |
2665 | 2662 |
2666 object.type = Dart_CObject_kBool; | 2663 object.type = Dart_CObject_kBool; |
2667 object.value.as_bool = true; | 2664 object.value.as_bool = true; |
2668 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2665 EXPECT(Dart_PostCObject(port_id, &object)); |
2669 | 2666 |
2670 object.type = Dart_CObject_kBool; | 2667 object.type = Dart_CObject_kBool; |
2671 object.value.as_bool = false; | 2668 object.value.as_bool = false; |
2672 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2669 EXPECT(Dart_PostCObject(port_id, &object)); |
2673 | 2670 |
2674 object.type = Dart_CObject_kInt32; | 2671 object.type = Dart_CObject_kInt32; |
2675 object.value.as_int32 = 123; | 2672 object.value.as_int32 = 123; |
2676 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2673 EXPECT(Dart_PostCObject(port_id, &object)); |
2677 | 2674 |
2678 object.type = Dart_CObject_kString; | 2675 object.type = Dart_CObject_kString; |
2679 object.value.as_string = const_cast<char*>("456"); | 2676 object.value.as_string = const_cast<char*>("456"); |
2680 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2677 EXPECT(Dart_PostCObject(port_id, &object)); |
2681 | 2678 |
2682 object.type = Dart_CObject_kString; | 2679 object.type = Dart_CObject_kString; |
2683 object.value.as_string = const_cast<char*>("æøå"); | 2680 object.value.as_string = const_cast<char*>("æøå"); |
2684 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2681 EXPECT(Dart_PostCObject(port_id, &object)); |
2685 | 2682 |
2686 object.type = Dart_CObject_kDouble; | 2683 object.type = Dart_CObject_kDouble; |
2687 object.value.as_double = 3.14; | 2684 object.value.as_double = 3.14; |
2688 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2685 EXPECT(Dart_PostCObject(port_id, &object)); |
2689 | 2686 |
2690 object.type = Dart_CObject_kArray; | 2687 object.type = Dart_CObject_kArray; |
2691 object.value.as_array.length = 0; | 2688 object.value.as_array.length = 0; |
2692 EXPECT(Dart_PostCObject(send_port_id, &object)); | 2689 EXPECT(Dart_PostCObject(port_id, &object)); |
2693 | 2690 |
2694 static const int kArrayLength = 10; | 2691 static const int kArrayLength = 10; |
2695 Dart_CObject* array = | 2692 Dart_CObject* array = |
2696 reinterpret_cast<Dart_CObject*>( | 2693 reinterpret_cast<Dart_CObject*>( |
2697 Dart_ScopeAllocate( | 2694 Dart_ScopeAllocate( |
2698 sizeof(Dart_CObject) + sizeof(Dart_CObject*) * kArrayLength)); //
NOLINT | 2695 sizeof(Dart_CObject) + sizeof(Dart_CObject*) * kArrayLength)); //
NOLINT |
2699 array->type = Dart_CObject_kArray; | 2696 array->type = Dart_CObject_kArray; |
2700 array->value.as_array.length = kArrayLength; | 2697 array->value.as_array.length = kArrayLength; |
2701 array->value.as_array.values = | 2698 array->value.as_array.values = |
2702 reinterpret_cast<Dart_CObject**>(array + 1); | 2699 reinterpret_cast<Dart_CObject**>(array + 1); |
2703 for (int i = 0; i < kArrayLength; i++) { | 2700 for (int i = 0; i < kArrayLength; i++) { |
2704 Dart_CObject* element = | 2701 Dart_CObject* element = |
2705 reinterpret_cast<Dart_CObject*>( | 2702 reinterpret_cast<Dart_CObject*>( |
2706 Dart_ScopeAllocate(sizeof(Dart_CObject))); | 2703 Dart_ScopeAllocate(sizeof(Dart_CObject))); |
2707 element->type = Dart_CObject_kInt32; | 2704 element->type = Dart_CObject_kInt32; |
2708 element->value.as_int32 = i; | 2705 element->value.as_int32 = i; |
2709 array->value.as_array.values[i] = element; | 2706 array->value.as_array.values[i] = element; |
2710 } | 2707 } |
2711 EXPECT(Dart_PostCObject(send_port_id, array)); | 2708 EXPECT(Dart_PostCObject(port_id, array)); |
2712 | 2709 |
2713 result = Dart_RunLoop(); | 2710 result = Dart_RunLoop(); |
2714 EXPECT(Dart_IsError(result)); | 2711 EXPECT(Dart_IsError(result)); |
2715 EXPECT(Dart_ErrorHasException(result)); | 2712 EXPECT(Dart_ErrorHasException(result)); |
2716 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2713 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
2717 Dart_GetError(result)); | 2714 Dart_GetError(result)); |
2718 | 2715 |
2719 Dart_ExitScope(); | 2716 Dart_ExitScope(); |
2720 } | 2717 } |
2721 | 2718 |
2722 #endif // !defined(TARGET_ARCH_ARM64) | 2719 #endif // !defined(TARGET_ARCH_ARM64) |
2723 | 2720 |
2724 } // namespace dart | 2721 } // namespace dart |
OLD | NEW |