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

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: Remove out dated comment and add/fix assert 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
« no previous file with comments | « 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
4043 // test ensures that when we change that we still throw on duplicate
4044 // constructors.
4045 const char* context_data[][2] = {{"class C {", "}"}, 4042 const char* context_data[][2] = {{"class C {", "}"},
4046 {"(class {", "});"}, 4043 {"(class {", "});"},
4047 {NULL, NULL}}; 4044 {NULL, NULL}};
4048 4045
4049 const char* class_body_data[] = { 4046 const char* class_body_data[] = {
4050 "constructor() {}; constructor() {}", 4047 "constructor() {}; constructor() {}",
4051 NULL}; 4048 NULL};
4052 4049
4053 static const ParserFlag always_flags[] = { 4050 static const ParserFlag always_flags[] = {
4054 kAllowClasses, 4051 kAllowClasses,
4055 kAllowHarmonyObjectLiterals 4052 kAllowHarmonyObjectLiterals
4056 }; 4053 };
4057 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 4054 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
4058 always_flags, arraysize(always_flags)); 4055 always_flags, arraysize(always_flags));
4059 } 4056 }
4060 4057
4061 4058
4062 // TODO(arv): We should allow duplicate property names. 4059 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 {", "}"}, 4060 const char* context_data[][2] = {{"class C {", "}"},
4066 {"(class {", "});"}, 4061 {"(class {", "});"},
4067 {NULL, NULL}}; 4062 {NULL, NULL}};
4068 4063
4069 const char* class_body_data[] = { 4064 const char* class_body_data[] = {
4070 "constructor() {}; static constructor() {}", 4065 "constructor() {}; static constructor() {}",
4071 "m() {}; static m() {}", 4066 "m() {}; static m() {}",
4072 "m() {}; m() {}", 4067 "m() {}; m() {}",
4068 "static m() {}; static m() {}",
4069 "get m() {}; set m(_) {}; get m() {}; set m(_) {};",
4073 NULL}; 4070 NULL};
4074 4071
4075 static const ParserFlag always_flags[] = { 4072 static const ParserFlag always_flags[] = {
4076 kAllowClasses, 4073 kAllowClasses,
4077 kAllowHarmonyObjectLiterals 4074 kAllowHarmonyObjectLiterals
4078 }; 4075 };
4079 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 4076 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
4080 always_flags, arraysize(always_flags)); 4077 always_flags, arraysize(always_flags));
4081 } 4078 }
4082 4079
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
4249 "for(const x = 4, y of [1,2,3]) {}", 4246 "for(const x = 4, y of [1,2,3]) {}",
4250 "for(const x = 1, y = 2 in []) {}", 4247 "for(const x = 1, y = 2 in []) {}",
4251 "for(const x,y in []) {}", 4248 "for(const x,y in []) {}",
4252 "for(const x = 1, y = 2 of []) {}", 4249 "for(const x = 1, y = 2 of []) {}",
4253 "for(const x,y of []) {}", 4250 "for(const x,y of []) {}",
4254 NULL}; 4251 NULL};
4255 static const ParserFlag always_flags[] = {kAllowHarmonyScoping}; 4252 static const ParserFlag always_flags[] = {kAllowHarmonyScoping};
4256 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 4253 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
4257 arraysize(always_flags)); 4254 arraysize(always_flags));
4258 } 4255 }
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698