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

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

Issue 869293002: Lexical declarations should not be allowed in Statement (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unused error messages Created 5 years, 10 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') | 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 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after
3781 NULL}; 3781 NULL};
3782 3782
3783 static const ParserFlag always_flags[] = { 3783 static const ParserFlag always_flags[] = {
3784 kAllowHarmonyClasses, kAllowHarmonySloppy}; 3784 kAllowHarmonyClasses, kAllowHarmonySloppy};
3785 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0, 3785 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0,
3786 always_flags, arraysize(always_flags)); 3786 always_flags, arraysize(always_flags));
3787 } 3787 }
3788 3788
3789 3789
3790 TEST(ClassDeclarationNoErrors) { 3790 TEST(ClassDeclarationNoErrors) {
3791 const char* context_data[][2] = {{"", ""}, 3791 const char* context_data[][2] = {{"'use strict'; ", ""},
3792 {"{", "}"}, 3792 {"'use strict'; {", "}"},
3793 {"if (true) {", "}"}, 3793 {"'use strict'; if (true) {", "}"},
3794 {NULL, NULL}}; 3794 {NULL, NULL}};
3795 const char* statement_data[] = { 3795 const char* statement_data[] = {
3796 "class name {}", 3796 "class name {}",
3797 "class name extends F {}", 3797 "class name extends F {}",
3798 "class name extends (F, G) {}", 3798 "class name extends (F, G) {}",
3799 "class name extends class {} {}", 3799 "class name extends class {} {}",
3800 "class name extends class base {} {}", 3800 "class name extends class base {} {}",
3801 NULL}; 3801 NULL};
3802 3802
3803 static const ParserFlag always_flags[] = { 3803 static const ParserFlag always_flags[] = {
3804 kAllowHarmonyClasses, kAllowHarmonySloppy}; 3804 kAllowHarmonyClasses, kAllowHarmonyScoping};
3805 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 3805 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
3806 always_flags, arraysize(always_flags)); 3806 always_flags, arraysize(always_flags));
3807 } 3807 }
3808 3808
3809 3809
3810 TEST(ClassBodyNoErrors) { 3810 TEST(ClassBodyNoErrors) {
3811 // Tests that parser and preparser accept valid class syntax. 3811 // Tests that parser and preparser accept valid class syntax.
3812 const char* context_data[][2] = {{"(class {", "});"}, 3812 const char* context_data[][2] = {{"(class {", "});"},
3813 {"(class extends Base {", "});"}, 3813 {"(class extends Base {", "});"},
3814 {"class C {", "}"}, 3814 {"class C {", "}"},
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
4824 NULL 4824 NULL
4825 }; 4825 };
4826 4826
4827 static const ParserFlag always_flags[] = { 4827 static const ParserFlag always_flags[] = {
4828 kAllowHarmonyComputedPropertyNames, 4828 kAllowHarmonyComputedPropertyNames,
4829 kAllowHarmonyObjectLiterals, 4829 kAllowHarmonyObjectLiterals,
4830 }; 4830 };
4831 RunParserSyncTest(context_data, error_data, kSuccess, NULL, 0, 4831 RunParserSyncTest(context_data, error_data, kSuccess, NULL, 0,
4832 always_flags, arraysize(always_flags)); 4832 always_flags, arraysize(always_flags));
4833 } 4833 }
4834
4835
4836 TEST(DeclarationsError) {
4837 const char* context_data[][2] = {{"'use strict'; if (true)", ""},
4838 {"'use strict'; if (false) {} else", ""},
4839 {"'use strict'; while (false)", ""},
4840 {"'use strict'; for (;;)", ""},
4841 {"'use strict'; for (x in y)", ""},
4842 {"'use strict'; do ", " while (false)"},
4843 {NULL, NULL}};
4844
4845 const char* statement_data[] = {
4846 "let x = 1;",
4847 "const x = 1;",
4848 "class C {}",
4849 NULL};
4850
4851 static const ParserFlag always_flags[] = {
4852 kAllowHarmonyClasses, kAllowHarmonyScoping
4853 };
4854 RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
4855 always_flags, arraysize(always_flags));
4856 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698