| 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/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-array-iterator.h" | 10 #include "src/interpreter/bytecode-array-iterator.h" |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 698 |
| 699 "function f() {\n" | 699 "function f() {\n" |
| 700 " var a = 0;\n" | 700 " var a = 0;\n" |
| 701 " if (a) {\n" | 701 " if (a) {\n" |
| 702 " return 20;\n" | 702 " return 20;\n" |
| 703 " } else {\n" | 703 " } else {\n" |
| 704 " return -20;\n" | 704 " return -20;\n" |
| 705 " }\n" | 705 " }\n" |
| 706 "};\n" | 706 "};\n" |
| 707 "f();\n", | 707 "f();\n", |
| 708 |
| 709 "function f(a, b) {\n" |
| 710 " if (a == b || a < 0) {\n" |
| 711 " return 1;\n" |
| 712 "} else if (a > 0 && b > 0) {\n" |
| 713 " return 0;\n" |
| 714 " } else {\n" |
| 715 " return -1;\n" |
| 716 " }\n" |
| 717 "};\n" |
| 718 "f(-1, 1);\n", |
| 708 }; | 719 }; |
| 709 | 720 |
| 710 CHECK(CompareTexts(BuildActual(printer, snippets), | 721 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 711 LoadGolden("IfConditions.golden"))); | 722 LoadGolden("IfConditions.golden"))); |
| 712 } | 723 } |
| 713 | 724 |
| 714 TEST(DeclareGlobals) { | 725 TEST(DeclareGlobals) { |
| 715 InitializedIgnitionHandleScope scope; | 726 InitializedIgnitionHandleScope scope; |
| 716 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 727 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
| 717 ConstantPoolType::kMixed); | 728 ConstantPoolType::kMixed); |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 CompareTexts(BuildActual(printer, snippets), LoadGolden("ForOf.golden"))); | 1618 CompareTexts(BuildActual(printer, snippets), LoadGolden("ForOf.golden"))); |
| 1608 } | 1619 } |
| 1609 | 1620 |
| 1610 TEST(Conditional) { | 1621 TEST(Conditional) { |
| 1611 InitializedIgnitionHandleScope scope; | 1622 InitializedIgnitionHandleScope scope; |
| 1612 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 1623 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
| 1613 ConstantPoolType::kNumber); | 1624 ConstantPoolType::kNumber); |
| 1614 const char* snippets[] = { | 1625 const char* snippets[] = { |
| 1615 "return 1 ? 2 : 3;\n", | 1626 "return 1 ? 2 : 3;\n", |
| 1616 | 1627 |
| 1617 "return 1 ? 2 ? 3 : 4 : 5;\n", | 1628 "return 0 ? 2 ? 3 : 4 : 5;\n", |
| 1629 |
| 1630 "return 0 < 1 ? 2 : 3;\n", |
| 1631 |
| 1632 "var x = 0;\n" |
| 1633 "return x ? 2 : 3;\n", |
| 1618 }; | 1634 }; |
| 1619 | 1635 |
| 1620 CHECK(CompareTexts(BuildActual(printer, snippets), | 1636 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 1621 LoadGolden("Conditional.golden"))); | 1637 LoadGolden("Conditional.golden"))); |
| 1622 } | 1638 } |
| 1623 | 1639 |
| 1624 TEST(Switch) { | 1640 TEST(Switch) { |
| 1625 InitializedIgnitionHandleScope scope; | 1641 InitializedIgnitionHandleScope scope; |
| 1626 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 1642 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
| 1627 ConstantPoolType::kNumber); | 1643 ConstantPoolType::kNumber); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 "f();\n", | 2258 "f();\n", |
| 2243 }; | 2259 }; |
| 2244 | 2260 |
| 2245 CHECK(CompareTexts(BuildActual(printer, snippets), | 2261 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 2246 LoadGolden("Generators.golden"))); | 2262 LoadGolden("Generators.golden"))); |
| 2247 } | 2263 } |
| 2248 | 2264 |
| 2249 } // namespace interpreter | 2265 } // namespace interpreter |
| 2250 } // namespace internal | 2266 } // namespace internal |
| 2251 } // namespace v8 | 2267 } // namespace v8 |
| OLD | NEW |