| 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 "vm/longjump.h" | 5 #include "vm/longjump.h" |
| 6 #include "vm/thread.h" | 6 #include "vm/thread.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| 11 static void LongJumpHelper(LongJumpScope* jump) { | 11 static void LongJumpHelper(LongJumpScope* jump) { |
| 12 const Error& error = Error::Handle( | 12 const Error& error = Error::Handle( |
| 13 LanguageError::New(String::Handle(String::New("LongJumpHelper")))); | 13 LanguageError::New(String::Handle(String::New("LongJumpHelper")))); |
| 14 jump->Jump(1, error); | 14 jump->Jump(1, error); |
| 15 UNREACHABLE(); | 15 UNREACHABLE(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 | |
| 19 TEST_CASE(LongJump) { | 18 TEST_CASE(LongJump) { |
| 20 LongJumpScope* base = Thread::Current()->long_jump_base(); | 19 LongJumpScope* base = Thread::Current()->long_jump_base(); |
| 21 { | 20 { |
| 22 LongJumpScope jump; | 21 LongJumpScope jump; |
| 23 if (setjmp(*jump.Set()) == 0) { | 22 if (setjmp(*jump.Set()) == 0) { |
| 24 LongJumpHelper(&jump); | 23 LongJumpHelper(&jump); |
| 25 UNREACHABLE(); | 24 UNREACHABLE(); |
| 26 } | 25 } |
| 27 } | 26 } |
| 28 ASSERT(base == Thread::Current()->long_jump_base()); | 27 ASSERT(base == Thread::Current()->long_jump_base()); |
| 29 } | 28 } |
| 30 | 29 |
| 31 } // namespace dart | 30 } // namespace dart |
| OLD | NEW |