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 25 matching lines...) Expand all Loading... | |
36 message = T.CheckThrowsReturnMessage(T.Val(2), T.undefined()); | 36 message = T.CheckThrowsReturnMessage(T.Val(2), T.undefined()); |
37 CHECK(!message.IsEmpty()); | 37 CHECK(!message.IsEmpty()); |
38 CHECK_EQ(3, message->GetLineNumber()); | 38 CHECK_EQ(3, message->GetLineNumber()); |
39 CHECK_EQ(67, message->GetStartPosition()); | 39 CHECK_EQ(67, message->GetStartPosition()); |
40 | 40 |
41 message = T.CheckThrowsReturnMessage(T.Val(3), T.undefined()); | 41 message = T.CheckThrowsReturnMessage(T.Val(3), T.undefined()); |
42 CHECK(!message.IsEmpty()); | 42 CHECK(!message.IsEmpty()); |
43 CHECK_EQ(4, message->GetLineNumber()); | 43 CHECK_EQ(4, message->GetLineNumber()); |
44 CHECK_EQ(95, message->GetStartPosition()); | 44 CHECK_EQ(95, message->GetStartPosition()); |
45 } | 45 } |
46 | |
47 | |
48 TEST(Catch) { | |
titzer
2015/02/02 09:47:29
+ 1
Good to have cctests for TurboFan, yay. Can w
Michael Starzinger
2015/02/02 14:47:41
The cases covered by these cases are already cover
| |
49 i::FLAG_turbo_exceptions = true; | |
50 const char* src = | |
51 "(function(a,b) {" | |
52 " var r = '-';" | |
53 " try {" | |
54 " r += 'A-';" | |
55 " throw 'B-';" | |
56 " } catch (e) {" | |
57 " r += e;" | |
58 " }" | |
59 " return r;" | |
60 "})"; | |
61 FunctionTester T(src); | |
62 | |
63 T.CheckCall(T.Val("-A-B-")); | |
64 } | |
65 | |
66 | |
67 TEST(CatchNested) { | |
68 i::FLAG_turbo_exceptions = true; | |
69 const char* src = | |
70 "(function(a,b) {" | |
71 " var r = '-';" | |
72 " try {" | |
73 " r += 'A-';" | |
74 " throw 'C-';" | |
75 " } catch (e) {" | |
76 " try {" | |
77 " throw 'B-';" | |
78 " } catch (e) {" | |
79 " r += e;" | |
80 " }" | |
81 " r += e;" | |
82 " }" | |
83 " return r;" | |
84 "})"; | |
85 FunctionTester T(src); | |
86 | |
87 T.CheckCall(T.Val("-A-B-C-")); | |
88 } | |
89 | |
90 | |
91 TEST(CatchBreak) { | |
92 i::FLAG_turbo_exceptions = true; | |
93 const char* src = | |
94 "(function(a,b) {" | |
95 " var r = '-';" | |
96 " L: try {" | |
97 " r += 'A-';" | |
98 " if (a) break L;" | |
99 " r += 'B-';" | |
100 " throw 'C-';" | |
101 " } catch (e) {" | |
102 " if (b) break L;" | |
103 " r += e;" | |
104 " }" | |
105 " r += 'D-';" | |
106 " return r;" | |
107 "})"; | |
108 FunctionTester T(src); | |
109 | |
110 T.CheckCall(T.Val("-A-D-"), T.true_value(), T.false_value()); | |
111 T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value()); | |
112 T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value()); | |
113 } | |
114 | |
115 | |
116 TEST(Finally) { | |
117 i::FLAG_turbo_exceptions = true; | |
118 const char* src = | |
119 "(function(a,b) {" | |
120 " var r = '-';" | |
121 " try {" | |
122 " r += 'A-';" | |
123 " } finally {" | |
124 " r += 'B-';" | |
125 " }" | |
126 " return r;" | |
127 "})"; | |
128 FunctionTester T(src); | |
129 | |
130 T.CheckCall(T.Val("-A-B-")); | |
131 } | |
132 | |
133 | |
134 TEST(FinallyBreak) { | |
135 i::FLAG_turbo_exceptions = true; | |
136 const char* src = | |
137 "(function(a,b) {" | |
138 " var r = '-';" | |
139 " L: try {" | |
140 " r += 'A-';" | |
141 " if (a) return r;" | |
142 " r += 'B-';" | |
143 " if (b) break L;" | |
144 " r += 'C-';" | |
145 " } finally {" | |
146 " r += 'D-';" | |
147 " }" | |
148 " return r;" | |
149 "})"; | |
150 FunctionTester T(src); | |
151 | |
152 T.CheckCall(T.Val("-A-"), T.true_value(), T.false_value()); | |
153 T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value()); | |
154 T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value()); | |
155 } | |
OLD | NEW |