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

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

Issue 1070633002: [strong] Implement static restrictions on binding/assignment to 'undefined' identifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase 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 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after
5838 }; 5838 };
5839 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, 5839 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags,
5840 arraysize(always_flags)); 5840 arraysize(always_flags));
5841 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, 5841 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5842 arraysize(always_flags)); 5842 arraysize(always_flags));
5843 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, 5843 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5844 arraysize(always_flags)); 5844 arraysize(always_flags));
5845 } 5845 }
5846 5846
5847 5847
5848 TEST(StrongUndefinedLocal) {
5849 const char* context_data[][2] = {{"", ""}, {NULL}};
5850
5851 const char* data[] = {
5852 "function undefined() {'use strong';}",
5853 "function* undefined() {'use strong';}",
5854 "(function undefined() {'use strong';});",
5855 "{foo: (function undefined(){'use strong';})};",
5856 "(function* undefined() {'use strong';})",
5857 "{foo: (function* undefined(){'use strong';})};",
5858 "function foo(a, b, undefined, c, d) {'use strong';}",
5859 "function* foo(a, b, undefined, c, d) {'use strong';}",
5860 "(function foo(a, b, undefined, c, d) {'use strong';})",
5861 "{foo: (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';})};",
5864 "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';} });",
5867 "{ *foo(a, b, undefined, c, d) {'use strong';} });",
5868 "class undefined {'use strong'}",
5869 "(class undefined {'use strong'});",
5870 NULL};
5871
5872 static const ParserFlag always_flags[] = {kAllowStrongMode};
5873
5874 RunParserSyncTest(context_data, data, kError, NULL, 0,
5875 always_flags, arraysize(always_flags));
5876 }
5877
5878
5848 TEST(ArrowFunctionASIErrors) { 5879 TEST(ArrowFunctionASIErrors) {
5849 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, 5880 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""},
5850 {NULL, NULL}}; 5881 {NULL, NULL}};
5851 5882
5852 const char* data[] = { 5883 const char* data[] = {
5853 "(a\n=> a)(1)", 5884 "(a\n=> a)(1)",
5854 "(a/*\n*/=> a)(1)", 5885 "(a/*\n*/=> a)(1)",
5855 "((a)\n=> a)(1)", 5886 "((a)\n=> a)(1)",
5856 "((a)/*\n*/=> a)(1)", 5887 "((a)/*\n*/=> a)(1)",
5857 "((a, b)\n=> a + b)(1, 2)", 5888 "((a, b)\n=> a + b)(1, 2)",
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 v8::Script::Compile(v8_str(script3)); 6035 v8::Script::Compile(v8_str(script3));
6005 CHECK(try_catch2.HasCaught()); 6036 CHECK(try_catch2.HasCaught());
6006 v8::String::Utf8Value exception(try_catch2.Exception()); 6037 v8::String::Utf8Value exception(try_catch2.Exception());
6007 CHECK_EQ(0, 6038 CHECK_EQ(0,
6008 strcmp( 6039 strcmp(
6009 "ReferenceError: In strong mode, using an undeclared global " 6040 "ReferenceError: In strong mode, using an undeclared global "
6010 "variable 'not_there3' is not allowed", 6041 "variable 'not_there3' is not allowed",
6011 *exception)); 6042 *exception));
6012 } 6043 }
6013 } 6044 }
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