| OLD | NEW |
| 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 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 | 1895 |
| 1896 | 1896 |
| 1897 void RunModuleParserSyncTest(const char* context_data[][2], | 1897 void RunModuleParserSyncTest(const char* context_data[][2], |
| 1898 const char* statement_data[], | 1898 const char* statement_data[], |
| 1899 ParserSyncTestResult result, | 1899 ParserSyncTestResult result, |
| 1900 const ParserFlag* flags = NULL, int flags_len = 0, | 1900 const ParserFlag* flags = NULL, int flags_len = 0, |
| 1901 const ParserFlag* always_true_flags = NULL, | 1901 const ParserFlag* always_true_flags = NULL, |
| 1902 int always_true_len = 0, | 1902 int always_true_len = 0, |
| 1903 const ParserFlag* always_false_flags = NULL, | 1903 const ParserFlag* always_false_flags = NULL, |
| 1904 int always_false_len = 0) { | 1904 int always_false_len = 0) { |
| 1905 bool flag = i::FLAG_harmony_modules; | |
| 1906 i::FLAG_harmony_modules = true; | |
| 1907 RunParserSyncTest(context_data, statement_data, result, flags, flags_len, | 1905 RunParserSyncTest(context_data, statement_data, result, flags, flags_len, |
| 1908 always_true_flags, always_true_len, always_false_flags, | 1906 always_true_flags, always_true_len, always_false_flags, |
| 1909 always_false_len, true); | 1907 always_false_len, true); |
| 1910 i::FLAG_harmony_modules = flag; | |
| 1911 } | 1908 } |
| 1912 | 1909 |
| 1913 | 1910 |
| 1914 TEST(ErrorsEvalAndArguments) { | 1911 TEST(ErrorsEvalAndArguments) { |
| 1915 // Tests that both preparsing and parsing produce the right kind of errors for | 1912 // Tests that both preparsing and parsing produce the right kind of errors for |
| 1916 // using "eval" and "arguments" as identifiers. Without the strict mode, it's | 1913 // using "eval" and "arguments" as identifiers. Without the strict mode, it's |
| 1917 // ok to use "eval" or "arguments" as identifiers. With the strict mode, it | 1914 // ok to use "eval" or "arguments" as identifiers. With the strict mode, it |
| 1918 // isn't. | 1915 // isn't. |
| 1919 const char* context_data[][2] = { | 1916 const char* context_data[][2] = { |
| 1920 {"\"use strict\";", ""}, | 1917 {"\"use strict\";", ""}, |
| (...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5572 | 5569 |
| 5573 static const ParserFlag always_flags[] = { | 5570 static const ParserFlag always_flags[] = { |
| 5574 kAllowHarmonySloppy, | 5571 kAllowHarmonySloppy, |
| 5575 }; | 5572 }; |
| 5576 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 5573 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 5577 always_flags, arraysize(always_flags)); | 5574 always_flags, arraysize(always_flags)); |
| 5578 } | 5575 } |
| 5579 | 5576 |
| 5580 | 5577 |
| 5581 TEST(BasicImportExportParsing) { | 5578 TEST(BasicImportExportParsing) { |
| 5582 i::FLAG_harmony_modules = true; | |
| 5583 | |
| 5584 // clang-format off | 5579 // clang-format off |
| 5585 const char* kSources[] = { | 5580 const char* kSources[] = { |
| 5586 "export let x = 0;", | 5581 "export let x = 0;", |
| 5587 "export var y = 0;", | 5582 "export var y = 0;", |
| 5588 "export const z = 0;", | 5583 "export const z = 0;", |
| 5589 "export function func() { };", | 5584 "export function func() { };", |
| 5590 "export class C { };", | 5585 "export class C { };", |
| 5591 "export { };", | 5586 "export { };", |
| 5592 "function f() {}; f(); export { f };", | 5587 "function f() {}; f(); export { f };", |
| 5593 "var a, b, c; export { a, b as baz, c };", | 5588 "var a, b, c; export { a, b as baz, c };", |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5672 i::ParseInfo info(&zone, script); | 5667 i::ParseInfo info(&zone, script); |
| 5673 i::Parser parser(&info); | 5668 i::Parser parser(&info); |
| 5674 info.set_global(); | 5669 info.set_global(); |
| 5675 CHECK(!parser.Parse(&info)); | 5670 CHECK(!parser.Parse(&info)); |
| 5676 } | 5671 } |
| 5677 } | 5672 } |
| 5678 } | 5673 } |
| 5679 | 5674 |
| 5680 | 5675 |
| 5681 TEST(ImportExportParsingErrors) { | 5676 TEST(ImportExportParsingErrors) { |
| 5682 i::FLAG_harmony_modules = true; | |
| 5683 | |
| 5684 // clang-format off | 5677 // clang-format off |
| 5685 const char* kErrorSources[] = { | 5678 const char* kErrorSources[] = { |
| 5686 "export {", | 5679 "export {", |
| 5687 "var a; export { a", | 5680 "var a; export { a", |
| 5688 "var a; export { a,", | 5681 "var a; export { a,", |
| 5689 "var a; export { a, ;", | 5682 "var a; export { a, ;", |
| 5690 "var a; export { a as };", | 5683 "var a; export { a as };", |
| 5691 "var a, b; export { a as , b};", | 5684 "var a, b; export { a as , b};", |
| 5692 "export }", | 5685 "export }", |
| 5693 "var foo, bar; export { foo bar };", | 5686 "var foo, bar; export { foo bar };", |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5763 i::Zone zone; | 5756 i::Zone zone; |
| 5764 i::ParseInfo info(&zone, script); | 5757 i::ParseInfo info(&zone, script); |
| 5765 i::Parser parser(&info); | 5758 i::Parser parser(&info); |
| 5766 info.set_module(); | 5759 info.set_module(); |
| 5767 CHECK(!parser.Parse(&info)); | 5760 CHECK(!parser.Parse(&info)); |
| 5768 } | 5761 } |
| 5769 } | 5762 } |
| 5770 | 5763 |
| 5771 | 5764 |
| 5772 TEST(ModuleParsingInternals) { | 5765 TEST(ModuleParsingInternals) { |
| 5773 i::FLAG_harmony_modules = true; | |
| 5774 | |
| 5775 i::Isolate* isolate = CcTest::i_isolate(); | 5766 i::Isolate* isolate = CcTest::i_isolate(); |
| 5776 i::Factory* factory = isolate->factory(); | 5767 i::Factory* factory = isolate->factory(); |
| 5777 v8::HandleScope handles(CcTest::isolate()); | 5768 v8::HandleScope handles(CcTest::isolate()); |
| 5778 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 5769 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 5779 v8::Context::Scope context_scope(context); | 5770 v8::Context::Scope context_scope(context); |
| 5780 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 5771 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 5781 128 * 1024); | 5772 128 * 1024); |
| 5782 | 5773 |
| 5783 static const char kSource[] = | 5774 static const char kSource[] = |
| 5784 "let x = 5;" | 5775 "let x = 5;" |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7294 RunParserSyncTest(sloppy_context, error_data, kError); | 7285 RunParserSyncTest(sloppy_context, error_data, kError); |
| 7295 RunParserSyncTest(sloppy_context, error_data, kError, NULL, 0, | 7286 RunParserSyncTest(sloppy_context, error_data, kError, NULL, 0, |
| 7296 restrictive_flags, arraysize(restrictive_flags)); | 7287 restrictive_flags, arraysize(restrictive_flags)); |
| 7297 RunParserSyncTest(sloppy_context, unrestricted_data, kSuccess); | 7288 RunParserSyncTest(sloppy_context, unrestricted_data, kSuccess); |
| 7298 RunParserSyncTest(sloppy_context, unrestricted_data, kError, NULL, 0, | 7289 RunParserSyncTest(sloppy_context, unrestricted_data, kError, NULL, 0, |
| 7299 restrictive_flags, arraysize(restrictive_flags)); | 7290 restrictive_flags, arraysize(restrictive_flags)); |
| 7300 RunParserSyncTest(sloppy_context, sloppy_data, kSuccess); | 7291 RunParserSyncTest(sloppy_context, sloppy_data, kSuccess); |
| 7301 RunParserSyncTest(sloppy_context, sloppy_data, kSuccess, restrictive_flags, | 7292 RunParserSyncTest(sloppy_context, sloppy_data, kSuccess, restrictive_flags, |
| 7302 arraysize(restrictive_flags)); | 7293 arraysize(restrictive_flags)); |
| 7303 } | 7294 } |
| OLD | NEW |