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

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

Issue 1060883004: [strong] Implement static restrictions on binding 'undefined' in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: linebreak Created 5 years, 8 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
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/undefined.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 5851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5862 "(function* foo(a, b, undefined, c, d) {'use strong';})", 5862 "(function* foo(a, b, undefined, c, d) {'use strong';})",
5863 "{foo: (function* foo(a, b, undefined, c, d) {'use strong';})};", 5863 "{foo: (function* foo(a, b, undefined, c, d) {'use strong';})};",
5864 "class C { foo(a, b, undefined, c, d) {'use strong';} }", 5864 "class C { foo(a, b, undefined, c, d) {'use strong';} }",
5865 "class C { *foo(a, b, undefined, c, d) {'use strong';} }", 5865 "class C { *foo(a, b, undefined, c, d) {'use strong';} }",
5866 "({ foo(a, b, undefined, c, d) {'use strong';} });", 5866 "({ foo(a, b, undefined, c, d) {'use strong';} });",
5867 "{ *foo(a, b, undefined, c, d) {'use strong';} });", 5867 "{ *foo(a, b, undefined, c, d) {'use strong';} });",
5868 "class undefined {'use strong'}", 5868 "class undefined {'use strong'}",
5869 "(class undefined {'use strong'});", 5869 "(class undefined {'use strong'});",
5870 NULL}; 5870 NULL};
5871 5871
5872 static const ParserFlag always_flags[] = {kAllowStrongMode}; 5872 static const ParserFlag always_flags[] = {
5873 kAllowStrongMode, kAllowHarmonySloppy
5874 };
5873 5875
5874 RunParserSyncTest(context_data, data, kError, NULL, 0, 5876 RunParserSyncTest(context_data, data, kError, NULL, 0,
5875 always_flags, arraysize(always_flags)); 5877 always_flags, arraysize(always_flags));
5876 } 5878 }
5877 5879
5878 5880
5881 TEST(StrongUndefinedArrow) {
5882 const char* sloppy_context_data[][2] = {{"", ""}, {NULL}};
5883 const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}};
5884 const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}};
5885
5886 const char* data[] = {
5887 "(undefined => {return});",
5888 "((undefined, b, c) => {return});",
5889 "((a, undefined, c) => {return});",
5890 "((a, b, undefined) => {return});",
5891 NULL};
5892
5893 const char* local_strong[] = {
5894 "(undefined => {'use strong';});",
5895 "((undefined, b, c) => {'use strong';});",
5896 "((a, undefined, c) => {'use strong';});",
5897 "((a, b, undefined) => {'use strong';});",
5898 NULL};
5899
5900 static const ParserFlag always_flags[] = {
5901 kAllowStrongMode, kAllowHarmonyArrowFunctions
5902 };
5903 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
5904 arraysize(always_flags));
5905 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5906 arraysize(always_flags));
5907 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5908 arraysize(always_flags));
5909 RunParserSyncTest(sloppy_context_data, local_strong, kError, NULL, 0,
5910 always_flags, arraysize(always_flags));
5911 }
5912
5913
5879 TEST(ArrowFunctionASIErrors) { 5914 TEST(ArrowFunctionASIErrors) {
5880 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, 5915 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""},
5881 {NULL, NULL}}; 5916 {NULL, NULL}};
5882 5917
5883 const char* data[] = { 5918 const char* data[] = {
5884 "(a\n=> a)(1)", 5919 "(a\n=> a)(1)",
5885 "(a/*\n*/=> a)(1)", 5920 "(a/*\n*/=> a)(1)",
5886 "((a)\n=> a)(1)", 5921 "((a)\n=> a)(1)",
5887 "((a)/*\n*/=> a)(1)", 5922 "((a)/*\n*/=> a)(1)",
5888 "((a, b)\n=> a + b)(1, 2)", 5923 "((a, b)\n=> a + b)(1, 2)",
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
6035 v8::Script::Compile(v8_str(script3)); 6070 v8::Script::Compile(v8_str(script3));
6036 CHECK(try_catch2.HasCaught()); 6071 CHECK(try_catch2.HasCaught());
6037 v8::String::Utf8Value exception(try_catch2.Exception()); 6072 v8::String::Utf8Value exception(try_catch2.Exception());
6038 CHECK_EQ(0, 6073 CHECK_EQ(0,
6039 strcmp( 6074 strcmp(
6040 "ReferenceError: In strong mode, using an undeclared global " 6075 "ReferenceError: In strong mode, using an undeclared global "
6041 "variable 'not_there3' is not allowed", 6076 "variable 'not_there3' is not allowed",
6042 *exception)); 6077 *exception));
6043 } 6078 }
6044 } 6079 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/undefined.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698