OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1742 "++super;", | 1742 "++super;", |
1743 "super++;", | 1743 "super++;", |
1744 "function foo super", | 1744 "function foo super", |
1745 NULL | 1745 NULL |
1746 }; | 1746 }; |
1747 | 1747 |
1748 RunParserSyncTest(context_data, statement_data, kError); | 1748 RunParserSyncTest(context_data, statement_data, kError); |
1749 } | 1749 } |
1750 | 1750 |
1751 | 1751 |
1752 TEST(NoErrorsLetSloppyAllModes) { | |
1753 // In sloppy mode, it's okay to use "let" as identifier. | |
1754 const char* context_data[][2] = { | |
1755 { "", "" }, | |
1756 { "function f() {", "}" }, | |
1757 { "(function f() {", "})" }, | |
1758 { NULL, NULL } | |
1759 }; | |
1760 | |
1761 const char* statement_data[] = { | |
1762 "var let;", | |
1763 "var foo, let;", | |
1764 "try { } catch (let) { }", | |
1765 "function let() { }", | |
1766 "(function let() { })", | |
1767 "function foo(let) { }", | |
1768 "function foo(bar, let) { }", | |
1769 "let = 1;", | |
1770 "var foo = let = 1;", | |
1771 "let * 2;", | |
1772 "++let;", | |
1773 "let++;", | |
1774 "let: 34", | |
1775 "function let(let) { let: let(let + let(0)); }", | |
1776 "({ let: 1 })", | |
1777 "({ get let() { 1 } })", | |
1778 "let(100)", | |
1779 NULL | |
1780 }; | |
1781 | |
1782 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | |
marja
2014/07/10 14:35:13
Afaics this test doesn't need kAllowArrowFunctions
rossberg
2014/07/10 14:39:00
Right, done.
| |
1783 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | |
1784 always_flags, ARRAY_SIZE(always_flags)); | |
1785 } | |
1786 | |
1787 | |
1752 TEST(NoErrorsYieldSloppyAllModes) { | 1788 TEST(NoErrorsYieldSloppyAllModes) { |
1753 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a | 1789 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a |
1754 // generator (see next test). | 1790 // generator (see other test). |
1755 const char* context_data[][2] = { | 1791 const char* context_data[][2] = { |
1756 { "", "" }, | 1792 { "", "" }, |
1757 { "function not_gen() {", "}" }, | 1793 { "function not_gen() {", "}" }, |
1758 { "(function not_gen() {", "})" }, | 1794 { "(function not_gen() {", "})" }, |
1759 { NULL, NULL } | 1795 { NULL, NULL } |
1760 }; | 1796 }; |
1761 | 1797 |
1762 const char* statement_data[] = { | 1798 const char* statement_data[] = { |
1763 "var yield;", | 1799 "var yield;", |
1764 "var foo, yield;", | 1800 "var foo, yield;", |
1765 "try { } catch (yield) { }", | 1801 "try { } catch (yield) { }", |
1766 "function yield() { }", | 1802 "function yield() { }", |
1767 "(function yield() { })", | 1803 "(function yield() { })", |
1768 "function foo(yield) { }", | 1804 "function foo(yield) { }", |
1769 "function foo(bar, yield) { }", | 1805 "function foo(bar, yield) { }", |
1770 "yield = 1;", | 1806 "yield = 1;", |
1771 "var foo = yield = 1;", | 1807 "var foo = yield = 1;", |
1808 "yield * 2;", | |
1772 "++yield;", | 1809 "++yield;", |
1773 "yield++;", | 1810 "yield++;", |
1774 "yield: 34", | 1811 "yield: 34", |
1775 "function yield(yield) { yield: yield (yield + yield (0)); }", | 1812 "function yield(yield) { yield: yield (yield + yield(0)); }", |
1776 "({ yield: 1 })", | 1813 "({ yield: 1 })", |
1777 "({ get yield() { 1 } })", | 1814 "({ get yield() { 1 } })", |
1778 "yield (100)", | 1815 "yield(100)", |
1816 "yield[100]", | |
1779 NULL | 1817 NULL |
1780 }; | 1818 }; |
1781 | 1819 |
1782 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | 1820 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
marja
2014/07/10 14:35:13
Namely here... we don't need kAllowArrowFunctions.
| |
1783 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 1821 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
1784 always_flags, ARRAY_SIZE(always_flags)); | 1822 always_flags, ARRAY_SIZE(always_flags)); |
1785 } | 1823 } |
1786 | 1824 |
1787 | 1825 |
1788 TEST(NoErrorsYieldSloppyGeneratorsEnabled) { | 1826 TEST(NoErrorsYieldSloppyGeneratorsEnabled) { |
1789 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a | 1827 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a |
1790 // generator (see next test). | 1828 // generator (see next test). |
1791 const char* context_data[][2] = { | 1829 const char* context_data[][2] = { |
1792 { "", "" }, | 1830 { "", "" }, |
1793 { "function not_gen() {", "}" }, | 1831 { "function not_gen() {", "}" }, |
1794 { "function * gen() { function not_gen() {", "} }" }, | 1832 { "function * gen() { function not_gen() {", "} }" }, |
1795 { "(function not_gen() {", "})" }, | 1833 { "(function not_gen() {", "})" }, |
1796 { "(function * gen() { (function not_gen() {", "}) })" }, | 1834 { "(function * gen() { (function not_gen() {", "}) })" }, |
1797 { NULL, NULL } | 1835 { NULL, NULL } |
1798 }; | 1836 }; |
1799 | 1837 |
1800 const char* statement_data[] = { | 1838 const char* statement_data[] = { |
1801 "var yield;", | 1839 "var yield;", |
1802 "var foo, yield;", | 1840 "var foo, yield;", |
1803 "try { } catch (yield) { }", | 1841 "try { } catch (yield) { }", |
1804 "function yield() { }", | 1842 "function yield() { }", |
1805 "(function yield() { })", | 1843 "(function yield() { })", |
1806 "function foo(yield) { }", | 1844 "function foo(yield) { }", |
1807 "function foo(bar, yield) { }", | 1845 "function foo(bar, yield) { }", |
1808 "function * yield() { }", | 1846 "function * yield() { }", |
1809 "(function * yield() { })", | 1847 "(function * yield() { })", |
1810 "yield = 1;", | 1848 "yield = 1;", |
1811 "var foo = yield = 1;", | 1849 "var foo = yield = 1;", |
1850 "yield * 2;", | |
1812 "++yield;", | 1851 "++yield;", |
1813 "yield++;", | 1852 "yield++;", |
1814 "yield: 34", | 1853 "yield: 34", |
1815 "function yield(yield) { yield: yield (yield + yield (0)); }", | 1854 "function yield(yield) { yield: yield (yield + yield(0)); }", |
1816 "({ yield: 1 })", | 1855 "({ yield: 1 })", |
1817 "({ get yield() { 1 } })", | 1856 "({ get yield() { 1 } })", |
1818 "yield (100)", | 1857 "yield(100)", |
1858 "yield[100]", | |
1819 NULL | 1859 NULL |
1820 }; | 1860 }; |
1821 | 1861 |
1822 // This test requires kAllowGenerators to succeed. | 1862 // This test requires kAllowGenerators to succeed. |
1823 static const ParserFlag always_true_flags[] = { | 1863 static const ParserFlag always_true_flags[] = { |
1824 kAllowGenerators | 1864 kAllowGenerators |
1825 }; | 1865 }; |
1826 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 1866 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
1827 always_true_flags, 1); | 1867 always_true_flags, 1); |
1828 } | 1868 } |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3101 | 3141 |
3102 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) | 3142 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) |
3103 "foo ? bar : baz => {}", | 3143 "foo ? bar : baz => {}", |
3104 NULL | 3144 NULL |
3105 }; | 3145 }; |
3106 | 3146 |
3107 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | 3147 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
3108 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3148 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
3109 always_flags, ARRAY_SIZE(always_flags)); | 3149 always_flags, ARRAY_SIZE(always_flags)); |
3110 } | 3150 } |
OLD | NEW |