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

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

Issue 1219853004: [es6] Initial support for let/const bindings in sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated tests and comments Created 5 years, 5 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 6748 matching lines...) Expand 10 before | Expand all | Expand 10 after
6759 }; 6759 };
6760 // clang-format on 6760 // clang-format on
6761 6761
6762 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, 6762 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags,
6763 arraysize(always_flags)); 6763 arraysize(always_flags));
6764 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, 6764 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags,
6765 arraysize(always_flags)); 6765 arraysize(always_flags));
6766 } 6766 }
6767 6767
6768 6768
6769 TEST(LegacyConst) { 6769 TEST(ConstLegacy) {
6770 // clang-format off 6770 // clang-format off
6771 const char* context_data[][2] = { 6771 const char* context_data[][2] = {
6772 {"", ""}, 6772 {"", ""},
6773 {"{", "}"}, 6773 {"{", "}"},
6774 {NULL, NULL} 6774 {NULL, NULL}
6775 }; 6775 };
6776 6776
6777 const char* data[] = { 6777 const char* data[] = {
6778 "const x", 6778 "const x",
6779 "const x = 1", 6779 "const x = 1",
6780 "for (const x = 1; x < 1; x++) {}", 6780 "for (const x = 1; x < 1; x++) {}",
6781 "for (const x in {}) {}", 6781 "for (const x in {}) {}",
6782 "for (const x of []) {}", 6782 "for (const x of []) {}",
6783 NULL 6783 NULL
6784 }; 6784 };
6785 // clang-format on 6785 // clang-format on
6786 6786
6787
6787 static const ParserFlag always_flags[] = {kNoLegacyConst}; 6788 static const ParserFlag always_flags[] = {kNoLegacyConst};
6788
6789 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6789 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6790 arraysize(always_flags)); 6790 arraysize(always_flags));
6791 RunParserSyncTest(context_data, data, kSuccess); 6791 RunParserSyncTest(context_data, data, kSuccess);
6792 } 6792 }
6793
6794
6795 TEST(ConstSloppy) {
6796 // clang-format off
6797 const char* context_data[][2] = {
6798 {"", ""},
6799 {"{", "}"},
6800 {NULL, NULL}
6801 };
6802
6803 const char* data[] = {
6804 "const x = 1",
6805 "for (const x = 1; x < 1; x++) {}",
6806 "for (const x in {}) {}",
6807 "for (const x of []) {}",
6808 NULL
6809 };
6810 // clang-format on
6811 static const ParserFlag always_flags[] = {kAllowHarmonySloppy,
6812 kNoLegacyConst};
6813 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6814 arraysize(always_flags));
6815 }
6816
6817
6818 TEST(LetSloppy) {
6819 // clang-format off
6820 const char* context_data[][2] = {
6821 {"", ""},
6822 {"'use strict';", ""},
6823 {"{", "}"},
6824 {NULL, NULL}
6825 };
6826
6827 const char* data[] = {
6828 "let x",
6829 "let x = 1",
6830 "for (let x = 1; x < 1; x++) {}",
6831 "for (let x in {}) {}",
6832 "for (let x of []) {}",
6833 NULL
6834 };
6835 // clang-format on
6836
6837 static const ParserFlag always_flags[] = {kAllowHarmonySloppy};
6838 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6839 arraysize(always_flags));
6840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698