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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 Dart_Handle lib = TestCase::LoadTestScript( | 563 Dart_Handle lib = TestCase::LoadTestScript( |
564 kScriptChars, &PropagateError_native_lookup); | 564 kScriptChars, &PropagateError_native_lookup); |
565 Dart_Handle result; | 565 Dart_Handle result; |
566 | 566 |
567 // Use Dart_PropagateError to propagate the error. | 567 // Use Dart_PropagateError to propagate the error. |
568 use_throw_exception = false; | 568 use_throw_exception = false; |
569 use_set_return = false; | 569 use_set_return = false; |
570 | 570 |
571 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); | 571 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); |
572 EXPECT(Dart_IsError(result)); | 572 EXPECT(Dart_IsError(result)); |
573 EXPECT(!Dart_ErrorHasException(result)); | |
574 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); | 573 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); |
575 | 574 |
576 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); | 575 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); |
577 EXPECT(Dart_IsError(result)); | 576 EXPECT(Dart_IsError(result)); |
578 EXPECT(Dart_ErrorHasException(result)); | 577 EXPECT(Dart_ErrorHasException(result)); |
579 EXPECT_SUBSTRING("myException", Dart_GetError(result)); | 578 EXPECT_SUBSTRING("myException", Dart_GetError(result)); |
580 | 579 |
581 // Use Dart_SetReturnValue to propagate the error. | 580 // Use Dart_SetReturnValue to propagate the error. |
582 use_throw_exception = false; | 581 use_throw_exception = false; |
583 use_set_return = true; | 582 use_set_return = true; |
584 | 583 |
585 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); | 584 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); |
586 EXPECT(Dart_IsError(result)); | 585 EXPECT(Dart_IsError(result)); |
587 EXPECT(!Dart_ErrorHasException(result)); | |
588 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); | 586 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); |
589 | 587 |
590 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); | 588 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); |
591 EXPECT(Dart_IsError(result)); | 589 EXPECT(Dart_IsError(result)); |
592 EXPECT(Dart_ErrorHasException(result)); | 590 EXPECT(Dart_ErrorHasException(result)); |
593 EXPECT_SUBSTRING("myException", Dart_GetError(result)); | 591 EXPECT_SUBSTRING("myException", Dart_GetError(result)); |
594 | 592 |
595 // Use Dart_ThrowException to propagate the error. | 593 // Use Dart_ThrowException to propagate the error. |
596 use_throw_exception = true; | 594 use_throw_exception = true; |
597 use_set_return = false; | 595 use_set_return = false; |
598 | 596 |
599 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); | 597 result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); |
600 EXPECT(Dart_IsError(result)); | 598 EXPECT(Dart_IsError(result)); |
601 EXPECT(!Dart_ErrorHasException(result)); | |
602 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); | 599 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); |
603 | 600 |
604 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); | 601 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); |
605 EXPECT(Dart_IsError(result)); | 602 EXPECT(Dart_IsError(result)); |
606 EXPECT(Dart_ErrorHasException(result)); | 603 EXPECT(Dart_ErrorHasException(result)); |
607 EXPECT_SUBSTRING("myException", Dart_GetError(result)); | 604 EXPECT_SUBSTRING("myException", Dart_GetError(result)); |
608 } | 605 } |
609 | 606 |
610 | 607 |
611 TEST_CASE(Dart_Error) { | 608 TEST_CASE(Dart_Error) { |
(...skipping 9602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10214 result = Dart_Invoke(lib, | 10211 result = Dart_Invoke(lib, |
10215 NewString("foozoo"), | 10212 NewString("foozoo"), |
10216 0, | 10213 0, |
10217 NULL); | 10214 NULL); |
10218 EXPECT(Dart_IsError(result)); | 10215 EXPECT(Dart_IsError(result)); |
10219 } | 10216 } |
10220 | 10217 |
10221 #endif // !PRODUCT | 10218 #endif // !PRODUCT |
10222 | 10219 |
10223 } // namespace dart | 10220 } // namespace dart |
OLD | NEW |