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

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

Issue 1314203002: [strong] Class constructor bodies cannot contain "use strong" directive (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 3 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
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 6080 matching lines...) Expand 10 before | Expand all | Expand 10 after
6091 6091
6092 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, 6092 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0,
6093 always_flags, arraysize(always_flags)); 6093 always_flags, arraysize(always_flags));
6094 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, 6094 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0,
6095 always_flags, arraysize(always_flags)); 6095 always_flags, arraysize(always_flags));
6096 RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0, 6096 RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0,
6097 always_flags, arraysize(always_flags)); 6097 always_flags, arraysize(always_flags));
6098 } 6098 }
6099 6099
6100 6100
6101 TEST(StrongConstructorDirective) {
6102 const char* context_data[][2] = {{"class c { ", " }"},
6103 {"(class c { ", " });"},
6104 {"let a = (class c { ", " });"},
6105 {NULL}};
6106
6107 const char* error_data[] = {
6108 "constructor() { \"use strong\" }",
6109 "constructor(...rest) { \"use strong\" }",
6110 "foo() {} constructor() { \"use strong\" }",
6111 "foo(...rest) { \"use strict\" } constructor() { \"use strong\" }", NULL};
6112
6113 const char* success_data[] = {
6114 "constructor() { \"use strict\" }", "foo() { \"use strong\" }",
6115 "foo() { \"use strong\" } constructor() {}", NULL};
6116
6117 static const ParserFlag always_flags[] = {
6118 kAllowHarmonyRestParameters, kAllowHarmonySloppy, kAllowHarmonySloppyLet,
6119 kAllowStrongMode};
6120
6121 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6122 arraysize(always_flags));
6123 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags,
6124 arraysize(always_flags));
6125 }
6126
6127
6101 TEST(StrongUndefinedLocal) { 6128 TEST(StrongUndefinedLocal) {
6102 const char* context_data[][2] = {{"", ""}, {NULL}}; 6129 const char* context_data[][2] = {{"", ""}, {NULL}};
6103 6130
6104 const char* data[] = { 6131 const char* data[] = {
6105 "function undefined() {'use strong';}", 6132 "function undefined() {'use strong';}",
6106 "function* undefined() {'use strong';}", 6133 "function* undefined() {'use strong';}",
6107 "(function undefined() {'use strong';});", 6134 "(function undefined() {'use strong';});",
6108 "{foo: (function undefined(){'use strong';})};", 6135 "{foo: (function undefined(){'use strong';})};",
6109 "(function* undefined() {'use strong';})", 6136 "(function* undefined() {'use strong';})",
6110 "{foo: (function* undefined(){'use strong';})};", 6137 "{foo: (function* undefined(){'use strong';})};",
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 NULL}; 7032 NULL};
7006 7033
7007 static const ParserFlag always_flags[] = { 7034 static const ParserFlag always_flags[] = {
7008 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters, 7035 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters,
7009 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters, 7036 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters,
7010 kAllowHarmonySloppy, kAllowStrongMode 7037 kAllowHarmonySloppy, kAllowStrongMode
7011 }; 7038 };
7012 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 7039 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
7013 arraysize(always_flags)); 7040 arraysize(always_flags));
7014 } 7041 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698