OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 TEST(CatchCall) { | 121 TEST(CatchCall) { |
122 i::FLAG_turbo_exceptions = true; | 122 i::FLAG_turbo_exceptions = true; |
123 const char* src = | 123 const char* src = |
124 "(function(fun) {" | 124 "(function(fun) {" |
125 " var r = '-';" | 125 " var r = '-';" |
126 " try {" | 126 " try {" |
127 " r += 'A-';" | 127 " r += 'A-';" |
128 " fun();" | 128 " return r + 'B-' + fun();" |
129 " } catch (e) {" | 129 " } catch (e) {" |
130 " r += e;" | 130 " r += e;" |
131 " }" | 131 " }" |
132 " return r;" | 132 " return r;" |
133 "})"; | 133 "})"; |
134 FunctionTester T(src); | 134 FunctionTester T(src); |
135 | 135 |
136 CompileRun("function thrower() { throw 'T-'; }"); | 136 CompileRun("function thrower() { throw 'T-'; }"); |
137 #if 0 // TODO(mstarzinger): Enable once we have exception handlers. | 137 #if 0 // TODO(mstarzinger): Enable once we have exception handlers. |
138 T.CheckCall(T.Val("-A-T-"), T.NewFunction("thrower")); | 138 T.CheckCall(T.Val("-A-T-"), T.NewFunction("thrower")); |
139 #endif | 139 #endif |
| 140 CompileRun("function returner() { return 'R-'; }"); |
| 141 T.CheckCall(T.Val("-A-B-R-"), T.NewFunction("returner")); |
140 } | 142 } |
141 | 143 |
142 | 144 |
143 TEST(Finally) { | 145 TEST(Finally) { |
144 i::FLAG_turbo_exceptions = true; | 146 i::FLAG_turbo_exceptions = true; |
145 const char* src = | 147 const char* src = |
146 "(function(a,b) {" | 148 "(function(a,b) {" |
147 " var r = '-';" | 149 " var r = '-';" |
148 " try {" | 150 " try {" |
149 " r += 'A-';" | 151 " r += 'A-';" |
(...skipping 23 matching lines...) Expand all Loading... |
173 " r += 'D-';" | 175 " r += 'D-';" |
174 " }" | 176 " }" |
175 " return r;" | 177 " return r;" |
176 "})"; | 178 "})"; |
177 FunctionTester T(src); | 179 FunctionTester T(src); |
178 | 180 |
179 T.CheckCall(T.Val("-A-"), T.true_value(), T.false_value()); | 181 T.CheckCall(T.Val("-A-"), T.true_value(), T.false_value()); |
180 T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value()); | 182 T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value()); |
181 T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value()); | 183 T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value()); |
182 } | 184 } |
OLD | NEW |