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

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

Issue 584993002: ES6: Implement object literal property shorthand (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/object-literals-property-shorthand.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 3951 matching lines...) Expand 10 before | Expand all | Expand 10 after
3962 "class C { *method() { with ({}) {} } }", 3962 "class C { *method() { with ({}) {} } }",
3963 NULL}; 3963 NULL};
3964 3964
3965 static const ParserFlag always_flags[] = { 3965 static const ParserFlag always_flags[] = {
3966 kAllowClasses, 3966 kAllowClasses,
3967 kAllowHarmonyObjectLiterals 3967 kAllowHarmonyObjectLiterals
3968 }; 3968 };
3969 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 3969 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
3970 always_flags, arraysize(always_flags)); 3970 always_flags, arraysize(always_flags));
3971 } 3971 }
3972
3973
3974 TEST(ObjectLiteralPropertyShorthandKeywordsError) {
3975 const char* context_data[][2] = {{"({", "});"},
3976 {"'use strict'; ({", "});"},
3977 {NULL, NULL}};
3978
3979 const char* name_data[] = {
3980 "break",
3981 "case",
3982 "catch",
3983 "class",
3984 "const",
3985 "continue",
3986 "debugger",
3987 "default",
3988 "delete",
3989 "do",
3990 "else",
3991 "enum",
3992 "export",
3993 "extends",
3994 "false",
3995 "finally",
3996 "for",
3997 "function",
3998 "if",
3999 "import",
4000 "in",
4001 "instanceof",
4002 "new",
4003 "null",
4004 "return",
4005 "super",
4006 "switch",
4007 "this",
4008 "throw",
4009 "true",
4010 "try",
4011 "typeof",
4012 "var",
4013 "void",
4014 "while",
4015 "with",
4016 NULL
4017 };
4018
4019 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
4020 RunParserSyncTest(context_data, name_data, kError, NULL, 0,
4021 always_flags, arraysize(always_flags));
4022 }
4023
4024
4025 TEST(ObjectLiteralPropertyShorthandStrictKeywords) {
4026 const char* context_data[][2] = {{"({", "});"},
4027 {NULL, NULL}};
4028
4029 const char* name_data[] = {
4030 "implements",
4031 "interface",
4032 "let",
4033 "package",
4034 "private",
4035 "protected",
4036 "public",
4037 "static",
4038 "yield",
4039 NULL
4040 };
4041
4042 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
4043 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0,
4044 always_flags, arraysize(always_flags));
4045
4046 const char* context_strict_data[][2] = {{"'use strict'; ({", "});"},
4047 {NULL, NULL}};
4048 RunParserSyncTest(context_strict_data, name_data, kError, NULL, 0,
4049 always_flags, arraysize(always_flags));
4050 }
4051
4052
4053 TEST(ObjectLiteralPropertyShorthandError) {
4054 const char* context_data[][2] = {{"({", "});"},
4055 {"'use strict'; ({", "});"},
4056 {NULL, NULL}};
4057
4058 const char* name_data[] = {
4059 "1",
4060 "1.2",
4061 "0",
4062 "0.1",
4063 "1.0",
4064 "1e1",
4065 "0x1",
4066 "\"s\"",
4067 "'s'",
4068 NULL
4069 };
4070
4071 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
4072 RunParserSyncTest(context_data, name_data, kError, NULL, 0,
4073 always_flags, arraysize(always_flags));
4074 }
4075
4076
4077 TEST(ObjectLiteralPropertyShorthandYieldInGeneratorError) {
4078 const char* context_data[][2] = {{"", ""},
4079 {NULL, NULL}};
4080
4081 const char* name_data[] = {
4082 "function* g() { ({yield}); }",
4083 NULL
4084 };
4085
4086 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
4087 RunParserSyncTest(context_data, name_data, kError, NULL, 0,
4088 always_flags, arraysize(always_flags));
4089 }
OLDNEW
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/object-literals-property-shorthand.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698