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

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

Issue 677953004: Allow duplicate property names in classes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | Annotate | Revision Log
« src/preparser.h ('K') | « src/preparser.h ('k') | 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 4021 matching lines...) Expand 10 before | Expand all | Expand 10 after
4032 static const ParserFlag always_flags[] = { 4032 static const ParserFlag always_flags[] = {
4033 kAllowClasses, 4033 kAllowClasses,
4034 kAllowHarmonyObjectLiterals 4034 kAllowHarmonyObjectLiterals
4035 }; 4035 };
4036 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 4036 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
4037 always_flags, arraysize(always_flags)); 4037 always_flags, arraysize(always_flags));
4038 } 4038 }
4039 4039
4040 4040
4041 TEST(ClassMultipleConstructorErrors) { 4041 TEST(ClassMultipleConstructorErrors) {
4042 // We currently do not allow any duplicate properties in class bodies. This 4042 // We currently do not allow any duplicate properties in class bodies. This
marja 2014/10/28 08:30:22 This comment seems out of date now.
4043 // test ensures that when we change that we still throw on duplicate 4043 // test ensures that when we change that we still throw on duplicate
4044 // constructors. 4044 // constructors.
4045 const char* context_data[][2] = {{"class C {", "}"}, 4045 const char* context_data[][2] = {{"class C {", "}"},
4046 {"(class {", "});"}, 4046 {"(class {", "});"},
4047 {NULL, NULL}}; 4047 {NULL, NULL}};
4048 4048
4049 const char* class_body_data[] = { 4049 const char* class_body_data[] = {
4050 "constructor() {}; constructor() {}", 4050 "constructor() {}; constructor() {}",
4051 NULL}; 4051 NULL};
4052 4052
4053 static const ParserFlag always_flags[] = { 4053 static const ParserFlag always_flags[] = {
4054 kAllowClasses, 4054 kAllowClasses,
4055 kAllowHarmonyObjectLiterals 4055 kAllowHarmonyObjectLiterals
4056 }; 4056 };
4057 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 4057 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
4058 always_flags, arraysize(always_flags)); 4058 always_flags, arraysize(always_flags));
4059 } 4059 }
4060 4060
4061 4061
4062 // TODO(arv): We should allow duplicate property names. 4062 TEST(ClassMultiplePropertyNamesNoErrors) {
4063 // https://code.google.com/p/v8/issues/detail?id=3570
4064 DISABLED_TEST(ClassMultiplePropertyNamesNoErrors) {
4065 const char* context_data[][2] = {{"class C {", "}"}, 4063 const char* context_data[][2] = {{"class C {", "}"},
4066 {"(class {", "});"}, 4064 {"(class {", "});"},
4067 {NULL, NULL}}; 4065 {NULL, NULL}};
4068 4066
4069 const char* class_body_data[] = { 4067 const char* class_body_data[] = {
4070 "constructor() {}; static constructor() {}", 4068 "constructor() {}; static constructor() {}",
4071 "m() {}; static m() {}", 4069 "m() {}; static m() {}",
4072 "m() {}; m() {}", 4070 "m() {}; m() {}",
4071 "static m() {}; static m() {}",
4072 "get m() {}; set m(_) {}; get m() {}; set m(_) {};",
4073 NULL}; 4073 NULL};
4074 4074
4075 static const ParserFlag always_flags[] = { 4075 static const ParserFlag always_flags[] = {
4076 kAllowClasses, 4076 kAllowClasses,
4077 kAllowHarmonyObjectLiterals 4077 kAllowHarmonyObjectLiterals
4078 }; 4078 };
4079 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 4079 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
4080 always_flags, arraysize(always_flags)); 4080 always_flags, arraysize(always_flags));
4081 } 4081 }
4082 4082
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
4249 "for(const x = 4, y of [1,2,3]) {}", 4249 "for(const x = 4, y of [1,2,3]) {}",
4250 "for(const x = 1, y = 2 in []) {}", 4250 "for(const x = 1, y = 2 in []) {}",
4251 "for(const x,y in []) {}", 4251 "for(const x,y in []) {}",
4252 "for(const x = 1, y = 2 of []) {}", 4252 "for(const x = 1, y = 2 of []) {}",
4253 "for(const x,y of []) {}", 4253 "for(const x,y of []) {}",
4254 NULL}; 4254 NULL};
4255 static const ParserFlag always_flags[] = {kAllowHarmonyScoping}; 4255 static const ParserFlag always_flags[] = {kAllowHarmonyScoping};
4256 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 4256 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
4257 arraysize(always_flags)); 4257 arraysize(always_flags));
4258 } 4258 }
OLDNEW
« src/preparser.h ('K') | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698