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

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

Issue 724713004: Reduce ErrorsFutureStrictReservedWords test to make it faster (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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 | « no previous file | 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 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 V(interface) \ 1833 V(interface) \
1834 V(let) \ 1834 V(let) \
1835 V(package) \ 1835 V(package) \
1836 V(private) \ 1836 V(private) \
1837 V(protected) \ 1837 V(protected) \
1838 V(public) \ 1838 V(public) \
1839 V(static) \ 1839 V(static) \
1840 V(yield) 1840 V(yield)
1841 1841
1842 1842
1843 #define LIMITED_FUTURE_STRICT_RESERVED_WORDS(V) \
1844 V(implements) \
1845 V(let) \
1846 V(static) \
1847 V(yield)
1848
1849
1843 #define FUTURE_STRICT_RESERVED_STATEMENTS(NAME) \ 1850 #define FUTURE_STRICT_RESERVED_STATEMENTS(NAME) \
1844 "var " #NAME ";", \ 1851 "var " #NAME ";", \
1845 "var foo, " #NAME ";", \ 1852 "var foo, " #NAME ";", \
1846 "try { } catch (" #NAME ") { }", \ 1853 "try { } catch (" #NAME ") { }", \
1847 "function " #NAME "() { }", \ 1854 "function " #NAME "() { }", \
1848 "(function " #NAME "() { })", \ 1855 "(function " #NAME "() { })", \
1849 "function foo(" #NAME ") { }", \ 1856 "function foo(" #NAME ") { }", \
1850 "function foo(bar, " #NAME ") { }", \ 1857 "function foo(bar, " #NAME ") { }", \
1851 #NAME " = 1;", \ 1858 #NAME " = 1;", \
1852 #NAME " += 1;", \ 1859 #NAME " += 1;", \
1853 "var foo = " #NAME " = 1;", \ 1860 "var foo = " #NAME " = 1;", \
1854 "++" #NAME ";", \ 1861 "++" #NAME ";", \
1855 #NAME " ++;", 1862 #NAME " ++;",
1856 1863
1857 1864
1858 TEST(ErrorsFutureStrictReservedWords) { 1865 TEST(ErrorsFutureStrictReservedWords) {
1859 // Tests that both preparsing and parsing produce the right kind of errors for 1866 // Tests that both preparsing and parsing produce the right kind of errors for
1860 // using future strict reserved words as identifiers. Without the strict mode, 1867 // using future strict reserved words as identifiers. Without the strict mode,
1861 // it's ok to use future strict reserved words as identifiers. With the strict 1868 // it's ok to use future strict reserved words as identifiers. With the strict
1862 // mode, it isn't. 1869 // mode, it isn't.
1863 const char* context_data[][2] = { 1870 const char* context_data[][2] = {
1864 { "\"use strict\";", "" },
1865 { "function test_func() {\"use strict\"; ", "}"}, 1871 { "function test_func() {\"use strict\"; ", "}"},
1866 { "() => { \"use strict\"; ", "}" }, 1872 { "() => { \"use strict\"; ", "}" },
1867 { NULL, NULL } 1873 { NULL, NULL }
1868 }; 1874 };
1869 1875
1870 const char* statement_data[] { 1876 const char* statement_data[] {
1871 FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) 1877 LIMITED_FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS)
1872 NULL 1878 NULL
1873 }; 1879 };
1874 1880
1875 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; 1881 static const ParserFlag always_flags[] = {kAllowArrowFunctions};
1876 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags, 1882 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
1877 arraysize(always_flags)); 1883 arraysize(always_flags));
1878 1884
1879 static const ParserFlag classes_flags[] = { 1885 static const ParserFlag classes_flags[] = {
1880 kAllowArrowFunctions, kAllowClasses, kAllowHarmonyScoping}; 1886 kAllowArrowFunctions, kAllowClasses, kAllowHarmonyScoping};
1881 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, 1887 RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
1882 classes_flags, arraysize(classes_flags)); 1888 classes_flags, arraysize(classes_flags));
1883 } 1889 }
1884 1890
1885 1891
1892 #undef LIMITED_FUTURE_STRICT_RESERVED_WORDS
1893
1894
1886 TEST(NoErrorsFutureStrictReservedWords) { 1895 TEST(NoErrorsFutureStrictReservedWords) {
1887 const char* context_data[][2] = { 1896 const char* context_data[][2] = {
1888 { "", "" }, 1897 { "", "" },
1889 { "function test_func() {", "}"}, 1898 { "function test_func() {", "}"},
1890 { "() => {", "}" }, 1899 { "() => {", "}" },
1891 { NULL, NULL } 1900 { NULL, NULL }
1892 }; 1901 };
1893 1902
1894 const char* statement_data[] = { 1903 const char* statement_data[] = {
1895 FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) 1904 FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS)
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 RunParserSyncTest(context_data, bad_data, kError, NULL, 0, always_flags, 4459 RunParserSyncTest(context_data, bad_data, kError, NULL, 0, always_flags,
4451 arraysize(always_flags)); 4460 arraysize(always_flags));
4452 4461
4453 const char* good_data[] = { 4462 const char* good_data[] = {
4454 "let = 1;", 4463 "let = 1;",
4455 "for(let = 1;;){}", 4464 "for(let = 1;;){}",
4456 NULL}; 4465 NULL};
4457 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, always_flags, 4466 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, always_flags,
4458 arraysize(always_flags)); 4467 arraysize(always_flags));
4459 } 4468 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698