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

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

Issue 348893007: Allow yield expressions without a RHS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update tests, fix function* () { yield* } 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/preparser.h ('k') | test/mjsunit/harmony/generators-iteration.js » ('j') | 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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 "yield * 2;", 1849 "yield * 2;",
1850 "yield * \n 2;", 1850 "yield * \n 2;",
1851 "yield yield 1;", 1851 "yield yield 1;",
1852 "yield * yield * 1;", 1852 "yield * yield * 1;",
1853 "yield 3 + (yield 4);", 1853 "yield 3 + (yield 4);",
1854 "yield * 3 + (yield * 4);", 1854 "yield * 3 + (yield * 4);",
1855 "(yield * 3) + (yield * 4);", 1855 "(yield * 3) + (yield * 4);",
1856 "yield 3; yield 4;", 1856 "yield 3; yield 4;",
1857 "yield * 3; yield * 4;", 1857 "yield * 3; yield * 4;",
1858 "(function (yield) { })", 1858 "(function (yield) { })",
1859 "yield { yield: 12 }",
1860 "yield /* comment */ { yield: 12 }",
1861 "yield * \n { yield: 12 }",
1862 "yield /* comment */ * \n { yield: 12 }",
1859 // You can return in a generator. 1863 // You can return in a generator.
1860 "yield 1; return", 1864 "yield 1; return",
1861 "yield * 1; return", 1865 "yield * 1; return",
1862 "yield 1; return 37", 1866 "yield 1; return 37",
1863 "yield * 1; return 37", 1867 "yield * 1; return 37",
1864 "yield 1; return 37; yield 'dead';", 1868 "yield 1; return 37; yield 'dead';",
1865 "yield * 1; return 37; yield * 'dead';", 1869 "yield * 1; return 37; yield * 'dead';",
1866 // Yield is still a valid key in object literals. 1870 // Yield is still a valid key in object literals.
1867 "({ yield: 1 })", 1871 "({ yield: 1 })",
1868 "({ get yield() { } })", 1872 "({ get yield() { } })",
1869 // TODO(348893007): Invalid (no newline allowed between yield and *). 1873 // Yield without RHS.
1870 "yield\n*3", 1874 "yield;",
1875 "yield",
1876 "yield\n",
1877 "yield /* comment */"
1878 "yield // comment\n"
1879 "(yield)",
1880 "[yield]",
1881 "{yield}",
1882 "yield, yield",
1883 "yield; yield",
1884 "(yield) ? yield : yield",
1885 "(yield) \n ? yield : yield",
1886 // If there is a newline before the next token, we don't look for RHS.
1887 "yield\nfor (;;) {}",
1871 NULL 1888 NULL
1872 }; 1889 };
1873 1890
1874 // This test requires kAllowGenerators to succeed. 1891 // This test requires kAllowGenerators to succeed.
1875 static const ParserFlag always_true_flags[] = { 1892 static const ParserFlag always_true_flags[] = {
1876 kAllowGenerators 1893 kAllowGenerators
1877 }; 1894 };
1878 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 1895 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
1879 always_true_flags, 1); 1896 always_true_flags, 1);
1880 } 1897 }
(...skipping 25 matching lines...) Expand all
1906 "yield++;", 1923 "yield++;",
1907 "yield *", 1924 "yield *",
1908 "(yield *)", 1925 "(yield *)",
1909 // Yield binds very loosely, so this parses as "yield (3 + yield 4)", which 1926 // Yield binds very loosely, so this parses as "yield (3 + yield 4)", which
1910 // is invalid. 1927 // is invalid.
1911 "yield 3 + yield 4;", 1928 "yield 3 + yield 4;",
1912 "yield: 34", 1929 "yield: 34",
1913 "yield ? 1 : 2", 1930 "yield ? 1 : 2",
1914 // Parses as yield (/ yield): invalid. 1931 // Parses as yield (/ yield): invalid.
1915 "yield / yield", 1932 "yield / yield",
1916 // TODO(348893007): The rest of these should be valid. 1933 "+ yield",
1917 "yield;", 1934 "+ yield 3",
1918 "yield", 1935 // Invalid (no newline allowed between yield and *).
1919 "yield\n", 1936 "yield\n*3",
1920 "(yield)", 1937 // Invalid (we see a newline, so we parse {yield:42} as a statement, not an
1921 "[yield]", 1938 // object literal, and yield is not a valid label).
1922 "{yield}", 1939 "yield\n{yield: 42}",
1923 "yield, yield", 1940 "yield /* comment */\n {yield: 42}",
1924 "yield; yield", 1941 "yield //comment\n {yield: 42}",
1925 "(yield) ? yield : yield",
1926 "(yield) \n ? yield : yield",
1927 // Parses as yield (+ yield).
1928 "yield + yield",
1929 NULL 1942 NULL
1930 }; 1943 };
1931 1944
1932 RunParserSyncTest(context_data, statement_data, kError); 1945 RunParserSyncTest(context_data, statement_data, kError);
1933 } 1946 }
1934 1947
1935 1948
1936 TEST(ErrorsNameOfStrictFunction) { 1949 TEST(ErrorsNameOfStrictFunction) {
1937 // Tests that illegal tokens as names of a strict function produce the correct 1950 // Tests that illegal tokens as names of a strict function produce the correct
1938 // errors. 1951 // errors.
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 LocalContext env; 2911 LocalContext env;
2899 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; 2912 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
2900 global_use_counts = use_counts; 2913 global_use_counts = use_counts;
2901 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); 2914 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
2902 CompileRun("\"use asm\";\n" 2915 CompileRun("\"use asm\";\n"
2903 "var foo = 1;\n" 2916 "var foo = 1;\n"
2904 "\"use asm\";\n" // Only the first one counts. 2917 "\"use asm\";\n" // Only the first one counts.
2905 "function bar() { \"use asm\"; var baz = 1; }"); 2918 "function bar() { \"use asm\"; var baz = 1; }");
2906 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]); 2919 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]);
2907 } 2920 }
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/mjsunit/harmony/generators-iteration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698