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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 385613002: Parser sync tests for `let` identifiers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 6 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 RunParserSyncTest(context_data, statement_data, kSuccess);
1783 }
1784
1785
1752 TEST(NoErrorsYieldSloppyAllModes) { 1786 TEST(NoErrorsYieldSloppyAllModes) {
1753 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a 1787 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a
1754 // generator (see next test). 1788 // generator (see other test).
1755 const char* context_data[][2] = { 1789 const char* context_data[][2] = {
1756 { "", "" }, 1790 { "", "" },
1757 { "function not_gen() {", "}" }, 1791 { "function not_gen() {", "}" },
1758 { "(function not_gen() {", "})" }, 1792 { "(function not_gen() {", "})" },
1759 { NULL, NULL } 1793 { NULL, NULL }
1760 }; 1794 };
1761 1795
1762 const char* statement_data[] = { 1796 const char* statement_data[] = {
1763 "var yield;", 1797 "var yield;",
1764 "var foo, yield;", 1798 "var foo, yield;",
1765 "try { } catch (yield) { }", 1799 "try { } catch (yield) { }",
1766 "function yield() { }", 1800 "function yield() { }",
1767 "(function yield() { })", 1801 "(function yield() { })",
1768 "function foo(yield) { }", 1802 "function foo(yield) { }",
1769 "function foo(bar, yield) { }", 1803 "function foo(bar, yield) { }",
1770 "yield = 1;", 1804 "yield = 1;",
1771 "var foo = yield = 1;", 1805 "var foo = yield = 1;",
1806 "yield * 2;",
1772 "++yield;", 1807 "++yield;",
1773 "yield++;", 1808 "yield++;",
1774 "yield: 34", 1809 "yield: 34",
1775 "function yield(yield) { yield: yield (yield + yield (0)); }", 1810 "function yield(yield) { yield: yield (yield + yield(0)); }",
1776 "({ yield: 1 })", 1811 "({ yield: 1 })",
1777 "({ get yield() { 1 } })", 1812 "({ get yield() { 1 } })",
1778 "yield (100)", 1813 "yield(100)",
1814 "yield[100]",
1779 NULL 1815 NULL
1780 }; 1816 };
1781 1817
1782 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; 1818 RunParserSyncTest(context_data, statement_data, kSuccess);
1783 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
1784 always_flags, ARRAY_SIZE(always_flags));
1785 } 1819 }
1786 1820
1787 1821
1788 TEST(NoErrorsYieldSloppyGeneratorsEnabled) { 1822 TEST(NoErrorsYieldSloppyGeneratorsEnabled) {
1789 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a 1823 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a
1790 // generator (see next test). 1824 // generator (see next test).
1791 const char* context_data[][2] = { 1825 const char* context_data[][2] = {
1792 { "", "" }, 1826 { "", "" },
1793 { "function not_gen() {", "}" }, 1827 { "function not_gen() {", "}" },
1794 { "function * gen() { function not_gen() {", "} }" }, 1828 { "function * gen() { function not_gen() {", "} }" },
1795 { "(function not_gen() {", "})" }, 1829 { "(function not_gen() {", "})" },
1796 { "(function * gen() { (function not_gen() {", "}) })" }, 1830 { "(function * gen() { (function not_gen() {", "}) })" },
1797 { NULL, NULL } 1831 { NULL, NULL }
1798 }; 1832 };
1799 1833
1800 const char* statement_data[] = { 1834 const char* statement_data[] = {
1801 "var yield;", 1835 "var yield;",
1802 "var foo, yield;", 1836 "var foo, yield;",
1803 "try { } catch (yield) { }", 1837 "try { } catch (yield) { }",
1804 "function yield() { }", 1838 "function yield() { }",
1805 "(function yield() { })", 1839 "(function yield() { })",
1806 "function foo(yield) { }", 1840 "function foo(yield) { }",
1807 "function foo(bar, yield) { }", 1841 "function foo(bar, yield) { }",
1808 "function * yield() { }", 1842 "function * yield() { }",
1809 "(function * yield() { })", 1843 "(function * yield() { })",
1810 "yield = 1;", 1844 "yield = 1;",
1811 "var foo = yield = 1;", 1845 "var foo = yield = 1;",
1846 "yield * 2;",
1812 "++yield;", 1847 "++yield;",
1813 "yield++;", 1848 "yield++;",
1814 "yield: 34", 1849 "yield: 34",
1815 "function yield(yield) { yield: yield (yield + yield (0)); }", 1850 "function yield(yield) { yield: yield (yield + yield(0)); }",
1816 "({ yield: 1 })", 1851 "({ yield: 1 })",
1817 "({ get yield() { 1 } })", 1852 "({ get yield() { 1 } })",
1818 "yield (100)", 1853 "yield(100)",
1854 "yield[100]",
1819 NULL 1855 NULL
1820 }; 1856 };
1821 1857
1822 // This test requires kAllowGenerators to succeed. 1858 // This test requires kAllowGenerators to succeed.
1823 static const ParserFlag always_true_flags[] = { 1859 static const ParserFlag always_true_flags[] = { kAllowGenerators };
1824 kAllowGenerators
1825 };
1826 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 1860 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
1827 always_true_flags, 1); 1861 always_true_flags, 1);
1828 } 1862 }
1829 1863
1830 1864
1831 TEST(ErrorsYieldStrict) { 1865 TEST(ErrorsYieldStrict) {
1832 const char* context_data[][2] = { 1866 const char* context_data[][2] = {
1833 { "\"use strict\";", "" }, 1867 { "\"use strict\";", "" },
1834 { "\"use strict\"; function not_gen() {", "}" }, 1868 { "\"use strict\"; function not_gen() {", "}" },
1835 { "function test_func() {\"use strict\"; ", "}"}, 1869 { "function test_func() {\"use strict\"; ", "}"},
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 3135
3102 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) 3136 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {})
3103 "foo ? bar : baz => {}", 3137 "foo ? bar : baz => {}",
3104 NULL 3138 NULL
3105 }; 3139 };
3106 3140
3107 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; 3141 static const ParserFlag always_flags[] = {kAllowArrowFunctions};
3108 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 3142 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
3109 always_flags, ARRAY_SIZE(always_flags)); 3143 always_flags, ARRAY_SIZE(always_flags));
3110 } 3144 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698