OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <fstream> | 5 #include <fstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/interpreter/bytecode-array-iterator.h" | 9 #include "src/interpreter/bytecode-array-iterator.h" |
10 #include "src/interpreter/bytecode-generator.h" | 10 #include "src/interpreter/bytecode-generator.h" |
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 "var a = { func: function() { } };\n", | 1243 "var a = { func: function() { } };\n", |
1244 }; | 1244 }; |
1245 | 1245 |
1246 CHECK(CompareTexts(BuildActual(printer, snippets), | 1246 CHECK(CompareTexts(BuildActual(printer, snippets), |
1247 LoadGolden("TopLevelObjectLiterals.golden"))); | 1247 LoadGolden("TopLevelObjectLiterals.golden"))); |
1248 } | 1248 } |
1249 | 1249 |
1250 TEST(TryCatch) { | 1250 TEST(TryCatch) { |
1251 InitializedIgnitionHandleScope scope; | 1251 InitializedIgnitionHandleScope scope; |
1252 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 1252 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
1253 ConstantPoolType::kString); | 1253 ConstantPoolType::kMixed); |
1254 | 1254 |
1255 const char* snippets[] = { | 1255 const char* snippets[] = { |
1256 "try { return 1; } catch(e) { return 2; }\n", | 1256 "try { return 1; } catch(e) { return 2; }\n", |
1257 | 1257 |
1258 "var a;\n" | 1258 "var a;\n" |
1259 "try { a = 1 } catch(e1) {};\n" | 1259 "try { a = 1 } catch(e1) {};\n" |
1260 "try { a = 2 } catch(e2) { a = 3 }\n", | 1260 "try { a = 2 } catch(e2) { a = 3 }\n", |
1261 }; | 1261 }; |
1262 | 1262 |
1263 CHECK(CompareTexts(BuildActual(printer, snippets), | 1263 CHECK(CompareTexts(BuildActual(printer, snippets), |
1264 LoadGolden("TryCatch.golden"))); | 1264 LoadGolden("TryCatch.golden"))); |
1265 } | 1265 } |
1266 | 1266 |
1267 TEST(TryFinally) { | 1267 TEST(TryFinally) { |
1268 InitializedIgnitionHandleScope scope; | 1268 InitializedIgnitionHandleScope scope; |
1269 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 1269 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
1270 ConstantPoolType::kString); | 1270 ConstantPoolType::kMixed); |
1271 const char* snippets[] = { | 1271 const char* snippets[] = { |
1272 "var a = 1;\n" | 1272 "var a = 1;\n" |
1273 "try { a = 2; } finally { a = 3; }\n", | 1273 "try { a = 2; } finally { a = 3; }\n", |
1274 | 1274 |
1275 "var a = 1;\n" | 1275 "var a = 1;\n" |
1276 "try { a = 2; } catch(e) { a = 20 } finally { a = 3; }\n", | 1276 "try { a = 2; } catch(e) { a = 20 } finally { a = 3; }\n", |
1277 | 1277 |
1278 "var a; try {\n" | 1278 "var a; try {\n" |
1279 " try { a = 1 } catch(e) { a = 2 }\n" | 1279 " try { a = 1 } catch(e) { a = 2 }\n" |
1280 "} catch(e) { a = 20 } finally { a = 3; }\n", | 1280 "} catch(e) { a = 20 } finally { a = 3; }\n", |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 "f();\n", | 2257 "f();\n", |
2258 }; | 2258 }; |
2259 | 2259 |
2260 CHECK(CompareTexts(BuildActual(printer, snippets), | 2260 CHECK(CompareTexts(BuildActual(printer, snippets), |
2261 LoadGolden("Generators.golden"))); | 2261 LoadGolden("Generators.golden"))); |
2262 } | 2262 } |
2263 | 2263 |
2264 } // namespace interpreter | 2264 } // namespace interpreter |
2265 } // namespace internal | 2265 } // namespace internal |
2266 } // namespace v8 | 2266 } // namespace v8 |
OLD | NEW |