| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Equal objects. | 100 // Equal objects. |
| 101 EXPECT_VALID(Dart_IsSame(five, five_again, &same)); | 101 EXPECT_VALID(Dart_IsSame(five, five_again, &same)); |
| 102 EXPECT(!same); | 102 EXPECT(!same); |
| 103 | 103 |
| 104 // Different objects. | 104 // Different objects. |
| 105 EXPECT_VALID(Dart_IsSame(five, seven, &same)); | 105 EXPECT_VALID(Dart_IsSame(five, seven, &same)); |
| 106 EXPECT(!same); | 106 EXPECT(!same); |
| 107 | 107 |
| 108 // Non-instance objects. | 108 // Non-instance objects. |
| 109 { | 109 { |
| 110 DARTSCOPE(Isolate::Current()); | 110 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 111 const Object& cls1 = Object::Handle(Object::null_class()); | 111 const Object& cls1 = Object::Handle(Object::null_class()); |
| 112 const Object& cls2 = Object::Handle(Object::class_class()); | 112 const Object& cls2 = Object::Handle(Object::class_class()); |
| 113 Dart_Handle class1 = Api::NewLocalHandle(cls1); | 113 Dart_Handle class1 = Api::NewLocalHandle(cls1); |
| 114 Dart_Handle class2 = Api::NewLocalHandle(cls2); | 114 Dart_Handle class2 = Api::NewLocalHandle(cls2); |
| 115 | 115 |
| 116 EXPECT_VALID(Dart_IsSame(class1, class1, &same)); | 116 EXPECT_VALID(Dart_IsSame(class1, class1, &same)); |
| 117 EXPECT(same); | 117 EXPECT(same); |
| 118 | 118 |
| 119 EXPECT_VALID(Dart_IsSame(class1, class2, &same)); | 119 EXPECT_VALID(Dart_IsSame(class1, class2, &same)); |
| 120 EXPECT(!same); | 120 EXPECT(!same); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 TestIsolateScope __test_isolate__; | 535 TestIsolateScope __test_isolate__; |
| 536 | 536 |
| 537 Isolate* isolate = Isolate::Current(); | 537 Isolate* isolate = Isolate::Current(); |
| 538 EXPECT(isolate != NULL); | 538 EXPECT(isolate != NULL); |
| 539 ApiState* state = isolate->api_state(); | 539 ApiState* state = isolate->api_state(); |
| 540 EXPECT(state != NULL); | 540 EXPECT(state != NULL); |
| 541 ApiLocalScope* scope = state->top_scope(); | 541 ApiLocalScope* scope = state->top_scope(); |
| 542 Dart_EnterScope(); | 542 Dart_EnterScope(); |
| 543 { | 543 { |
| 544 EXPECT(state->top_scope() != NULL); | 544 EXPECT(state->top_scope() != NULL); |
| 545 DARTSCOPE(isolate); | 545 DARTSCOPE_NOCHECKS(isolate); |
| 546 const String& str1 = String::Handle(String::New("Test String")); | 546 const String& str1 = String::Handle(String::New("Test String")); |
| 547 Dart_Handle ref = Api::NewLocalHandle(str1); | 547 Dart_Handle ref = Api::NewLocalHandle(str1); |
| 548 String& str2 = String::Handle(); | 548 String& str2 = String::Handle(); |
| 549 str2 ^= Api::UnwrapHandle(ref); | 549 str2 ^= Api::UnwrapHandle(ref); |
| 550 EXPECT(str1.Equals(str2)); | 550 EXPECT(str1.Equals(str2)); |
| 551 } | 551 } |
| 552 Dart_ExitScope(); | 552 Dart_ExitScope(); |
| 553 EXPECT(scope == state->top_scope()); | 553 EXPECT(scope == state->top_scope()); |
| 554 } | 554 } |
| 555 | 555 |
| 556 | 556 |
| 557 // Unit test for creating and deleting persistent handles. | 557 // Unit test for creating and deleting persistent handles. |
| 558 UNIT_TEST_CASE(PersistentHandles) { | 558 UNIT_TEST_CASE(PersistentHandles) { |
| 559 const char* kTestString1 = "Test String1"; | 559 const char* kTestString1 = "Test String1"; |
| 560 const char* kTestString2 = "Test String2"; | 560 const char* kTestString2 = "Test String2"; |
| 561 TestCase::CreateTestIsolate(); | 561 TestCase::CreateTestIsolate(); |
| 562 Isolate* isolate = Isolate::Current(); | 562 Isolate* isolate = Isolate::Current(); |
| 563 EXPECT(isolate != NULL); | 563 EXPECT(isolate != NULL); |
| 564 ApiState* state = isolate->api_state(); | 564 ApiState* state = isolate->api_state(); |
| 565 EXPECT(state != NULL); | 565 EXPECT(state != NULL); |
| 566 ApiLocalScope* scope = state->top_scope(); | 566 ApiLocalScope* scope = state->top_scope(); |
| 567 Dart_Handle handles[2000]; | 567 Dart_Handle handles[2000]; |
| 568 Dart_EnterScope(); | 568 Dart_EnterScope(); |
| 569 { | 569 { |
| 570 DARTSCOPE(isolate); | 570 DARTSCOPE_NOCHECKS(isolate); |
| 571 const String& str1 = String::Handle(String::New(kTestString1)); | 571 const String& str1 = String::Handle(String::New(kTestString1)); |
| 572 Dart_Handle ref1 = Api::NewLocalHandle(str1); | 572 Dart_Handle ref1 = Api::NewLocalHandle(str1); |
| 573 for (int i = 0; i < 1000; i++) { | 573 for (int i = 0; i < 1000; i++) { |
| 574 handles[i] = Dart_NewPersistentHandle(ref1); | 574 handles[i] = Dart_NewPersistentHandle(ref1); |
| 575 } | 575 } |
| 576 Dart_EnterScope(); | 576 Dart_EnterScope(); |
| 577 const String& str2 = String::Handle(String::New(kTestString2)); | 577 const String& str2 = String::Handle(String::New(kTestString2)); |
| 578 Dart_Handle ref2 = Api::NewLocalHandle(str2); | 578 Dart_Handle ref2 = Api::NewLocalHandle(str2); |
| 579 for (int i = 1000; i < 2000; i++) { | 579 for (int i = 1000; i < 2000; i++) { |
| 580 handles[i] = Dart_NewPersistentHandle(ref2); | 580 handles[i] = Dart_NewPersistentHandle(ref2); |
| 581 } | 581 } |
| 582 for (int i = 500; i < 1500; i++) { | 582 for (int i = 500; i < 1500; i++) { |
| 583 Dart_DeletePersistentHandle(handles[i]); | 583 Dart_DeletePersistentHandle(handles[i]); |
| 584 } | 584 } |
| 585 for (int i = 500; i < 1000; i++) { | 585 for (int i = 500; i < 1000; i++) { |
| 586 handles[i] = Dart_NewPersistentHandle(ref2); | 586 handles[i] = Dart_NewPersistentHandle(ref2); |
| 587 } | 587 } |
| 588 for (int i = 1000; i < 1500; i++) { | 588 for (int i = 1000; i < 1500; i++) { |
| 589 handles[i] = Dart_NewPersistentHandle(ref1); | 589 handles[i] = Dart_NewPersistentHandle(ref1); |
| 590 } | 590 } |
| 591 VERIFY_ON_TRANSITION; | 591 VERIFY_ON_TRANSITION; |
| 592 Dart_ExitScope(); | 592 Dart_ExitScope(); |
| 593 } | 593 } |
| 594 Dart_ExitScope(); | 594 Dart_ExitScope(); |
| 595 { | 595 { |
| 596 DARTSCOPE(isolate); | 596 DARTSCOPE_NOCHECKS(isolate); |
| 597 for (int i = 0; i < 500; i++) { | 597 for (int i = 0; i < 500; i++) { |
| 598 String& str = String::Handle(); | 598 String& str = String::Handle(); |
| 599 str ^= Api::UnwrapHandle(handles[i]); | 599 str ^= Api::UnwrapHandle(handles[i]); |
| 600 EXPECT(str.Equals(kTestString1)); | 600 EXPECT(str.Equals(kTestString1)); |
| 601 } | 601 } |
| 602 for (int i = 500; i < 1000; i++) { | 602 for (int i = 500; i < 1000; i++) { |
| 603 String& str = String::Handle(); | 603 String& str = String::Handle(); |
| 604 str ^= Api::UnwrapHandle(handles[i]); | 604 str ^= Api::UnwrapHandle(handles[i]); |
| 605 EXPECT(str.Equals(kTestString2)); | 605 EXPECT(str.Equals(kTestString2)); |
| 606 } | 606 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // scope. | 653 // scope. |
| 654 UNIT_TEST_CASE(LocalHandles) { | 654 UNIT_TEST_CASE(LocalHandles) { |
| 655 TestCase::CreateTestIsolate(); | 655 TestCase::CreateTestIsolate(); |
| 656 Isolate* isolate = Isolate::Current(); | 656 Isolate* isolate = Isolate::Current(); |
| 657 EXPECT(isolate != NULL); | 657 EXPECT(isolate != NULL); |
| 658 ApiState* state = isolate->api_state(); | 658 ApiState* state = isolate->api_state(); |
| 659 EXPECT(state != NULL); | 659 EXPECT(state != NULL); |
| 660 ApiLocalScope* scope = state->top_scope(); | 660 ApiLocalScope* scope = state->top_scope(); |
| 661 Dart_Handle handles[300]; | 661 Dart_Handle handles[300]; |
| 662 { | 662 { |
| 663 DARTSCOPE(isolate); | 663 DARTSCOPE_NOCHECKS(isolate); |
| 664 Smi& val = Smi::Handle(); | 664 Smi& val = Smi::Handle(); |
| 665 | 665 |
| 666 // Start a new scope and allocate some local handles. | 666 // Start a new scope and allocate some local handles. |
| 667 Dart_EnterScope(); | 667 Dart_EnterScope(); |
| 668 for (int i = 0; i < 100; i++) { | 668 for (int i = 0; i < 100; i++) { |
| 669 val ^= Smi::New(i); | 669 val ^= Smi::New(i); |
| 670 handles[i] = Api::NewLocalHandle(val); | 670 handles[i] = Api::NewLocalHandle(val); |
| 671 } | 671 } |
| 672 EXPECT_EQ(100, state->CountLocalHandles()); | 672 EXPECT_EQ(100, state->CountLocalHandles()); |
| 673 for (int i = 0; i < 100; i++) { | 673 for (int i = 0; i < 100; i++) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 | 1019 |
| 1020 // Load up a test script in the test library. | 1020 // Load up a test script in the test library. |
| 1021 | 1021 |
| 1022 // Invoke a function which returns an object of type NativeFields. | 1022 // Invoke a function which returns an object of type NativeFields. |
| 1023 result = Dart_InvokeStatic(lib, | 1023 result = Dart_InvokeStatic(lib, |
| 1024 Dart_NewString("NativeFieldsTest"), | 1024 Dart_NewString("NativeFieldsTest"), |
| 1025 Dart_NewString("testMain"), | 1025 Dart_NewString("testMain"), |
| 1026 0, | 1026 0, |
| 1027 NULL); | 1027 NULL); |
| 1028 EXPECT_VALID(result); | 1028 EXPECT_VALID(result); |
| 1029 DARTSCOPE(Isolate::Current()); | 1029 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1030 Instance& obj = Instance::Handle(); | 1030 Instance& obj = Instance::Handle(); |
| 1031 obj ^= Api::UnwrapHandle(result); | 1031 obj ^= Api::UnwrapHandle(result); |
| 1032 const Class& cls = Class::Handle(obj.clazz()); | 1032 const Class& cls = Class::Handle(obj.clazz()); |
| 1033 // We expect the newly created "NativeFields" object to have | 1033 // We expect the newly created "NativeFields" object to have |
| 1034 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. | 1034 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. |
| 1035 // Hence the size of an instance of "NativeFields" should be | 1035 // Hence the size of an instance of "NativeFields" should be |
| 1036 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. | 1036 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. |
| 1037 // We check to make sure the instance size computed by the VM matches | 1037 // We check to make sure the instance size computed by the VM matches |
| 1038 // our expectations. | 1038 // our expectations. |
| 1039 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, | 1039 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, | 1105 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, |
| 1106 native_field_lookup); | 1106 native_field_lookup); |
| 1107 | 1107 |
| 1108 // Invoke a function which returns an object of type NativeFields. | 1108 // Invoke a function which returns an object of type NativeFields. |
| 1109 result = Dart_InvokeStatic(lib, | 1109 result = Dart_InvokeStatic(lib, |
| 1110 Dart_NewString("NativeFieldsTest"), | 1110 Dart_NewString("NativeFieldsTest"), |
| 1111 Dart_NewString("testMain"), | 1111 Dart_NewString("testMain"), |
| 1112 0, | 1112 0, |
| 1113 NULL); | 1113 NULL); |
| 1114 EXPECT_VALID(result); | 1114 EXPECT_VALID(result); |
| 1115 DARTSCOPE(Isolate::Current()); | 1115 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1116 Instance& obj = Instance::Handle(); | 1116 Instance& obj = Instance::Handle(); |
| 1117 obj ^= Api::UnwrapHandle(result); | 1117 obj ^= Api::UnwrapHandle(result); |
| 1118 const Class& cls = Class::Handle(obj.clazz()); | 1118 const Class& cls = Class::Handle(obj.clazz()); |
| 1119 // We expect the newly created "NativeFields" object to have | 1119 // We expect the newly created "NativeFields" object to have |
| 1120 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. | 1120 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. |
| 1121 // Hence the size of an instance of "NativeFields" should be | 1121 // Hence the size of an instance of "NativeFields" should be |
| 1122 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. | 1122 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. |
| 1123 // We check to make sure the instance size computed by the VM matches | 1123 // We check to make sure the instance size computed by the VM matches |
| 1124 // our expectations. | 1124 // our expectations. |
| 1125 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, | 1125 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 " return obj;\n" | 1338 " return obj;\n" |
| 1339 " }\n" | 1339 " }\n" |
| 1340 " static Function testMain2() {\n" | 1340 " static Function testMain2() {\n" |
| 1341 " return function() {};\n" | 1341 " return function() {};\n" |
| 1342 " }\n" | 1342 " }\n" |
| 1343 "}\n"; | 1343 "}\n"; |
| 1344 Dart_Handle result; | 1344 Dart_Handle result; |
| 1345 | 1345 |
| 1346 TestIsolateScope __test_isolate__; | 1346 TestIsolateScope __test_isolate__; |
| 1347 { | 1347 { |
| 1348 DARTSCOPE(Isolate::Current()); | 1348 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1349 | 1349 |
| 1350 // Create a test library and Load up a test script in it. | 1350 // Create a test library and Load up a test script in it. |
| 1351 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1351 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 1352 | 1352 |
| 1353 // Invoke a function which returns an object of type NativeFields. | 1353 // Invoke a function which returns an object of type NativeFields. |
| 1354 Dart_Handle retobj = Dart_InvokeStatic(lib, | 1354 Dart_Handle retobj = Dart_InvokeStatic(lib, |
| 1355 Dart_NewString("NativeFieldsTest"), | 1355 Dart_NewString("NativeFieldsTest"), |
| 1356 Dart_NewString("testMain1"), | 1356 Dart_NewString("testMain1"), |
| 1357 0, | 1357 0, |
| 1358 NULL); | 1358 NULL); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 "class InvokeDynamicTest {\n" | 1510 "class InvokeDynamicTest {\n" |
| 1511 " static InvokeDynamic testMain() {\n" | 1511 " static InvokeDynamic testMain() {\n" |
| 1512 " InvokeDynamic obj = new InvokeDynamic(10, 20);\n" | 1512 " InvokeDynamic obj = new InvokeDynamic(10, 20);\n" |
| 1513 " return obj;\n" | 1513 " return obj;\n" |
| 1514 " }\n" | 1514 " }\n" |
| 1515 "}\n"; | 1515 "}\n"; |
| 1516 Dart_Handle result; | 1516 Dart_Handle result; |
| 1517 | 1517 |
| 1518 TestIsolateScope __test_isolate__; | 1518 TestIsolateScope __test_isolate__; |
| 1519 { | 1519 { |
| 1520 DARTSCOPE(Isolate::Current()); | 1520 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1521 | 1521 |
| 1522 // Create a test library and Load up a test script in it. | 1522 // Create a test library and Load up a test script in it. |
| 1523 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1523 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 1524 | 1524 |
| 1525 // Invoke a function which returns an object of type InvokeDynamic. | 1525 // Invoke a function which returns an object of type InvokeDynamic. |
| 1526 Dart_Handle retobj = Dart_InvokeStatic(lib, | 1526 Dart_Handle retobj = Dart_InvokeStatic(lib, |
| 1527 Dart_NewString("InvokeDynamicTest"), | 1527 Dart_NewString("InvokeDynamicTest"), |
| 1528 Dart_NewString("testMain"), | 1528 Dart_NewString("testMain"), |
| 1529 0, | 1529 0, |
| 1530 NULL); | 1530 NULL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 " return obj.method1(10);\n" | 1575 " return obj.method1(10);\n" |
| 1576 " }\n" | 1576 " }\n" |
| 1577 " static Function testMain2() {\n" | 1577 " static Function testMain2() {\n" |
| 1578 " return InvokeClosure.method2(10);\n" | 1578 " return InvokeClosure.method2(10);\n" |
| 1579 " }\n" | 1579 " }\n" |
| 1580 "}\n"; | 1580 "}\n"; |
| 1581 Dart_Handle result; | 1581 Dart_Handle result; |
| 1582 | 1582 |
| 1583 TestIsolateScope __test_isolate__; | 1583 TestIsolateScope __test_isolate__; |
| 1584 { | 1584 { |
| 1585 DARTSCOPE(Isolate::Current()); | 1585 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1586 | 1586 |
| 1587 // Create a test library and Load up a test script in it. | 1587 // Create a test library and Load up a test script in it. |
| 1588 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1588 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 1589 | 1589 |
| 1590 // Invoke a function which returns a closure. | 1590 // Invoke a function which returns a closure. |
| 1591 Dart_Handle retobj = Dart_InvokeStatic(lib, | 1591 Dart_Handle retobj = Dart_InvokeStatic(lib, |
| 1592 Dart_NewString("InvokeClosureTest"), | 1592 Dart_NewString("InvokeClosureTest"), |
| 1593 Dart_NewString("testMain1"), | 1593 Dart_NewString("testMain1"), |
| 1594 0, | 1594 0, |
| 1595 NULL); | 1595 NULL); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 // Check that error is returned if null is passed as a class argument. | 1852 // Check that error is returned if null is passed as a class argument. |
| 1853 result = Dart_ObjectIsType(null, null, &is_instance); | 1853 result = Dart_ObjectIsType(null, null, &is_instance); |
| 1854 EXPECT(Dart_IsError(result)); | 1854 EXPECT(Dart_IsError(result)); |
| 1855 } | 1855 } |
| 1856 } | 1856 } |
| 1857 | 1857 |
| 1858 | 1858 |
| 1859 UNIT_TEST_CASE(NullReceiver) { | 1859 UNIT_TEST_CASE(NullReceiver) { |
| 1860 TestIsolateScope __test_isolate__; | 1860 TestIsolateScope __test_isolate__; |
| 1861 { | 1861 { |
| 1862 DARTSCOPE(Isolate::Current()); | 1862 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1863 | 1863 |
| 1864 Dart_Handle function_name = Dart_NewString("toString"); | 1864 Dart_Handle function_name = Dart_NewString("toString"); |
| 1865 const int number_of_arguments = 0; | 1865 const int number_of_arguments = 0; |
| 1866 Dart_Handle null_receiver = Api::NewLocalHandle(Object::Handle()); | 1866 Dart_Handle null_receiver = Api::NewLocalHandle(Object::Handle()); |
| 1867 Dart_Handle result = Dart_InvokeDynamic(null_receiver, | 1867 Dart_Handle result = Dart_InvokeDynamic(null_receiver, |
| 1868 function_name, | 1868 function_name, |
| 1869 number_of_arguments, | 1869 number_of_arguments, |
| 1870 NULL); | 1870 NULL); |
| 1871 EXPECT_VALID(result); | 1871 EXPECT_VALID(result); |
| 1872 EXPECT(Dart_IsString(result)); | 1872 EXPECT(Dart_IsString(result)); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 "}\n" | 2651 "}\n" |
| 2652 "\n" | 2652 "\n" |
| 2653 "void main(message) {\n" | 2653 "void main(message) {\n" |
| 2654 " new MyIsolate().spawn().then((port) {\n" | 2654 " new MyIsolate().spawn().then((port) {\n" |
| 2655 " port.call(message).receive((message, replyTo) {\n" | 2655 " port.call(message).receive((message, replyTo) {\n" |
| 2656 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" | 2656 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" |
| 2657 " });\n" | 2657 " });\n" |
| 2658 " });\n" | 2658 " });\n" |
| 2659 "}\n"; | 2659 "}\n"; |
| 2660 | 2660 |
| 2661 if (Dart_CurrentIsolate() != NULL) { |
| 2662 Dart_ExitIsolate(); |
| 2663 } |
| 2661 Dart_Isolate isolate = TestCase::CreateTestIsolate(); | 2664 Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
| 2662 ASSERT(isolate != NULL); | 2665 ASSERT(isolate != NULL); |
| 2663 Dart_EnterScope(); | 2666 Dart_EnterScope(); |
| 2664 Dart_Handle url = Dart_NewString(TestCase::url()); | 2667 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2665 Dart_Handle source = Dart_NewString(kScriptChars); | 2668 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2666 Dart_Handle lib = Dart_LoadScript(url, source, TestCase::library_handler); | 2669 Dart_Handle lib = Dart_LoadScript(url, source, TestCase::library_handler); |
| 2667 EXPECT_VALID(lib); | 2670 EXPECT_VALID(lib); |
| 2668 Dart_ExitScope(); | 2671 Dart_ExitScope(); |
| 2669 return true; | 2672 return true; |
| 2670 } | 2673 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2704 } | 2707 } |
| 2705 | 2708 |
| 2706 | 2709 |
| 2707 UNIT_TEST_CASE(RunLoop_Exception) { | 2710 UNIT_TEST_CASE(RunLoop_Exception) { |
| 2708 RunLoopTest(true); | 2711 RunLoopTest(true); |
| 2709 } | 2712 } |
| 2710 | 2713 |
| 2711 #endif // TARGET_ARCH_IA32. | 2714 #endif // TARGET_ARCH_IA32. |
| 2712 | 2715 |
| 2713 } // namespace dart | 2716 } // namespace dart |
| OLD | NEW |