| 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/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/allocation.h" | 6 #include "vm/allocation.h" |
| 7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 int data = 1; | 81 int data = 1; |
| 82 StackAllocatedDestructionHelper(&data); | 82 StackAllocatedDestructionHelper(&data); |
| 83 EXPECT_EQ(4, data); | 83 EXPECT_EQ(4, data); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 static void StackAllocatedLongJumpHelper(int* ptr, LongJump* jump) { | 87 static void StackAllocatedLongJumpHelper(int* ptr, LongJump* jump) { |
| 88 TestValueObject stacked(ptr); | 88 TestValueObject stacked(ptr); |
| 89 EXPECT_EQ(2, *ptr); | 89 EXPECT_EQ(2, *ptr); |
| 90 *ptr = 3; | 90 *ptr = 3; |
| 91 jump->Jump(1, "StackAllocatedLongJump Test"); | 91 const Error& error = |
| 92 Error::Handle(LanguageError::New( |
| 93 String::Handle(String::New("StackAllocatedLongJump")))); |
| 94 jump->Jump(1, error); |
| 92 UNREACHABLE(); | 95 UNREACHABLE(); |
| 93 } | 96 } |
| 94 | 97 |
| 95 | 98 |
| 96 TEST_CASE(StackAllocatedLongJump) { | 99 TEST_CASE(StackAllocatedLongJump) { |
| 97 LongJump jump; | 100 LongJump jump; |
| 98 int data = 1; | 101 int data = 1; |
| 99 if (setjmp(*jump.Set()) == 0) { | 102 if (setjmp(*jump.Set()) == 0) { |
| 100 StackAllocatedLongJumpHelper(&data, &jump); | 103 StackAllocatedLongJumpHelper(&data, &jump); |
| 101 UNREACHABLE(); | 104 UNREACHABLE(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 125 int data = 1; | 128 int data = 1; |
| 126 StackResourceDestructionHelper(&data); | 129 StackResourceDestructionHelper(&data); |
| 127 EXPECT_EQ(7, data); | 130 EXPECT_EQ(7, data); |
| 128 } | 131 } |
| 129 | 132 |
| 130 | 133 |
| 131 static void StackedStackResourceLongJumpHelper(int* ptr, LongJump* jump) { | 134 static void StackedStackResourceLongJumpHelper(int* ptr, LongJump* jump) { |
| 132 TestStackedStackResource stacked(ptr); | 135 TestStackedStackResource stacked(ptr); |
| 133 EXPECT_EQ(4, *ptr); | 136 EXPECT_EQ(4, *ptr); |
| 134 *ptr = 5; | 137 *ptr = 5; |
| 135 jump->Jump(1, "StackResourceLongJump Test"); | 138 const Error& error = |
| 139 Error::Handle(LanguageError::New( |
| 140 String::Handle(String::New("StackedStackResourceLongJump")))); |
| 141 jump->Jump(1, error); |
| 136 UNREACHABLE(); | 142 UNREACHABLE(); |
| 137 } | 143 } |
| 138 | 144 |
| 139 | 145 |
| 140 static void StackResourceLongJumpHelper(int* ptr, LongJump* jump) { | 146 static void StackResourceLongJumpHelper(int* ptr, LongJump* jump) { |
| 141 TestStackResource stacked(ptr); | 147 TestStackResource stacked(ptr); |
| 142 EXPECT_EQ(2, *ptr); | 148 EXPECT_EQ(2, *ptr); |
| 143 *ptr = 3; | 149 *ptr = 3; |
| 144 StackedStackResourceLongJumpHelper(ptr, jump); | 150 StackedStackResourceLongJumpHelper(ptr, jump); |
| 145 UNREACHABLE(); | 151 UNREACHABLE(); |
| 146 } | 152 } |
| 147 | 153 |
| 148 | 154 |
| 149 TEST_CASE(StackResourceLongJump) { | 155 TEST_CASE(StackResourceLongJump) { |
| 150 LongJump jump; | 156 LongJump jump; |
| 151 int data = 1; | 157 int data = 1; |
| 152 if (setjmp(*jump.Set()) == 0) { | 158 if (setjmp(*jump.Set()) == 0) { |
| 153 StackResourceLongJumpHelper(&data, &jump); | 159 StackResourceLongJumpHelper(&data, &jump); |
| 154 UNREACHABLE(); | 160 UNREACHABLE(); |
| 155 } | 161 } |
| 156 EXPECT_EQ(7, data); | 162 EXPECT_EQ(7, data); |
| 157 } | 163 } |
| 158 | 164 |
| 159 } // namespace dart | 165 } // namespace dart |
| OLD | NEW |