Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/cctest/compiler/test-run-jsexceptions.cc

Issue 1408283006: Remove deprecated API usage from compiler cctests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_turbofan-arguments-inline-3
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/test-run-jscalls.cc ('k') | test/cctest/compiler/test-run-jsobjects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7
5 #include "src/v8.h" 8 #include "src/v8.h"
6 9
7 #include "test/cctest/compiler/function-tester.h" 10 #include "test/cctest/compiler/function-tester.h"
8 11
9 using namespace v8::internal; 12 using namespace v8::internal;
10 using namespace v8::internal::compiler; 13 using namespace v8::internal::compiler;
11 14
12 TEST(Throw) { 15 TEST(Throw) {
13 FunctionTester T("(function(a,b) { if (a) { throw b; } else { return b; }})"); 16 FunctionTester T("(function(a,b) { if (a) { throw b; } else { return b; }})");
14 17
15 T.CheckThrows(T.true_value(), T.NewObject("new Error")); 18 T.CheckThrows(T.true_value(), T.NewObject("new Error"));
16 T.CheckCall(T.Val(23), T.false_value(), T.Val(23)); 19 T.CheckCall(T.Val(23), T.false_value(), T.Val(23));
17 } 20 }
18 21
19 22
20 TEST(ThrowMessagePosition) { 23 TEST(ThrowMessagePosition) {
21 static const char* src = 24 static const char* src =
22 "(function(a, b) { \n" 25 "(function(a, b) { \n"
23 " if (a == 1) throw 1; \n" 26 " if (a == 1) throw 1; \n"
24 " if (a == 2) {throw 2} \n" 27 " if (a == 2) {throw 2} \n"
25 " if (a == 3) {0;throw 3}\n" 28 " if (a == 3) {0;throw 3}\n"
26 " throw 4; \n" 29 " throw 4; \n"
27 "}) "; 30 "}) ";
28 FunctionTester T(src); 31 FunctionTester T(src);
29 v8::Handle<v8::Message> message; 32 v8::Local<v8::Message> message;
33 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
30 34
31 message = T.CheckThrowsReturnMessage(T.Val(1), T.undefined()); 35 message = T.CheckThrowsReturnMessage(T.Val(1), T.undefined());
32 CHECK_EQ(2, message->GetLineNumber()); 36 CHECK_EQ(2, message->GetLineNumber(context).FromMaybe(-1));
33 CHECK_EQ(40, message->GetStartPosition()); 37 CHECK_EQ(40, message->GetStartPosition());
34 38
35 message = T.CheckThrowsReturnMessage(T.Val(2), T.undefined()); 39 message = T.CheckThrowsReturnMessage(T.Val(2), T.undefined());
36 CHECK_EQ(3, message->GetLineNumber()); 40 CHECK_EQ(3, message->GetLineNumber(context).FromMaybe(-1));
37 CHECK_EQ(67, message->GetStartPosition()); 41 CHECK_EQ(67, message->GetStartPosition());
38 42
39 message = T.CheckThrowsReturnMessage(T.Val(3), T.undefined()); 43 message = T.CheckThrowsReturnMessage(T.Val(3), T.undefined());
40 CHECK_EQ(4, message->GetLineNumber()); 44 CHECK_EQ(4, message->GetLineNumber(context).FromMaybe(-1));
41 CHECK_EQ(95, message->GetStartPosition()); 45 CHECK_EQ(95, message->GetStartPosition());
42 } 46 }
43 47
44 48
45 TEST(ThrowMessageDirectly) { 49 TEST(ThrowMessageDirectly) {
46 static const char* src = 50 static const char* src =
47 "(function(a, b) {" 51 "(function(a, b) {"
48 " if (a) { throw b; } else { throw new Error(b); }" 52 " if (a) { throw b; } else { throw new Error(b); }"
49 "})"; 53 "})";
50 FunctionTester T(src); 54 FunctionTester T(src);
51 v8::Handle<v8::Message> message; 55 v8::Local<v8::Message> message;
56 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
57 v8::Maybe<bool> t = v8::Just(true);
52 58
53 message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?")); 59 message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?"));
54 CHECK(message->Get()->Equals(v8_str("Uncaught Error: Wat?"))); 60 CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Error: Wat?")));
55 61
56 message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!")); 62 message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!"));
57 CHECK(message->Get()->Equals(v8_str("Uncaught Kaboom!"))); 63 CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Kaboom!")));
58 } 64 }
59 65
60 66
61 TEST(ThrowMessageIndirectly) { 67 TEST(ThrowMessageIndirectly) {
62 i::FLAG_turbo_try_finally = true; 68 i::FLAG_turbo_try_finally = true;
63 static const char* src = 69 static const char* src =
64 "(function(a, b) {" 70 "(function(a, b) {"
65 " try {" 71 " try {"
66 " if (a) { throw b; } else { throw new Error(b); }" 72 " if (a) { throw b; } else { throw new Error(b); }"
67 " } finally {" 73 " } finally {"
68 " try { throw 'clobber'; } catch (e) { 'unclobber'; }" 74 " try { throw 'clobber'; } catch (e) { 'unclobber'; }"
69 " }" 75 " }"
70 "})"; 76 "})";
71 FunctionTester T(src); 77 FunctionTester T(src);
72 v8::Handle<v8::Message> message; 78 v8::Local<v8::Message> message;
79 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
80 v8::Maybe<bool> t = v8::Just(true);
73 81
74 message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?")); 82 message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?"));
75 CHECK(message->Get()->Equals(v8_str("Uncaught Error: Wat?"))); 83 CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Error: Wat?")));
76 84
77 message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!")); 85 message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!"));
78 CHECK(message->Get()->Equals(v8_str("Uncaught Kaboom!"))); 86 CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Kaboom!")));
79 } 87 }
80 88
81 89
82 TEST(Catch) { 90 TEST(Catch) {
83 const char* src = 91 const char* src =
84 "(function(a,b) {" 92 "(function(a,b) {"
85 " var r = '-';" 93 " var r = '-';"
86 " try {" 94 " try {"
87 " r += 'A-';" 95 " r += 'A-';"
88 " throw 'B-';" 96 " throw 'B-';"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 " } finally {" 273 " } finally {"
266 " %DeoptimizeFunction(f);" 274 " %DeoptimizeFunction(f);"
267 " }" 275 " }"
268 "})"; 276 "})";
269 FunctionTester T(src); 277 FunctionTester T(src);
270 278
271 #if 0 // TODO(mstarzinger): Enable once we can. 279 #if 0 // TODO(mstarzinger): Enable once we can.
272 T.CheckThrows(T.NewObject("new Error"), T.Val(1)); 280 T.CheckThrows(T.NewObject("new Error"), T.Val(1));
273 #endif 281 #endif
274 } 282 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-jscalls.cc ('k') | test/cctest/compiler/test-run-jsobjects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698