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 5610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5621 | 5621 |
5622 i::Handle<i::Script> script = factory->NewScript(source); | 5622 i::Handle<i::Script> script = factory->NewScript(source); |
5623 i::Zone zone(CcTest::i_isolate()->allocator()); | 5623 i::Zone zone(CcTest::i_isolate()->allocator()); |
5624 i::ParseInfo info(&zone, script); | 5624 i::ParseInfo info(&zone, script); |
5625 i::Parser parser(&info); | 5625 i::Parser parser(&info); |
5626 info.set_module(); | 5626 info.set_module(); |
5627 CHECK(!parser.Parse(&info)); | 5627 CHECK(!parser.Parse(&info)); |
5628 } | 5628 } |
5629 } | 5629 } |
5630 | 5630 |
| 5631 TEST(ModuleTopLevelFunctionDecl) { |
| 5632 // clang-format off |
| 5633 const char* kErrorSources[] = { |
| 5634 "function f() {} function f() {}", |
| 5635 "var f; function f() {}", |
| 5636 "function f() {} var f;", |
| 5637 "function* f() {} function* f() {}", |
| 5638 "var f; function* f() {}", |
| 5639 "function* f() {} var f;", |
| 5640 "function f() {} function* f() {}", |
| 5641 "function* f() {} function f() {}", |
| 5642 }; |
| 5643 // clang-format on |
| 5644 |
| 5645 i::Isolate* isolate = CcTest::i_isolate(); |
| 5646 i::Factory* factory = isolate->factory(); |
| 5647 |
| 5648 v8::HandleScope handles(CcTest::isolate()); |
| 5649 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 5650 v8::Context::Scope context_scope(context); |
| 5651 |
| 5652 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 5653 128 * 1024); |
| 5654 |
| 5655 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { |
| 5656 i::Handle<i::String> source = |
| 5657 factory->NewStringFromAsciiChecked(kErrorSources[i]); |
| 5658 |
| 5659 i::Handle<i::Script> script = factory->NewScript(source); |
| 5660 i::Zone zone(CcTest::i_isolate()->allocator()); |
| 5661 i::ParseInfo info(&zone, script); |
| 5662 i::Parser parser(&info); |
| 5663 info.set_module(); |
| 5664 CHECK(!parser.Parse(&info)); |
| 5665 } |
| 5666 } |
| 5667 |
5631 | 5668 |
5632 TEST(ModuleParsingInternals) { | 5669 TEST(ModuleParsingInternals) { |
5633 i::Isolate* isolate = CcTest::i_isolate(); | 5670 i::Isolate* isolate = CcTest::i_isolate(); |
5634 i::Factory* factory = isolate->factory(); | 5671 i::Factory* factory = isolate->factory(); |
5635 v8::HandleScope handles(CcTest::isolate()); | 5672 v8::HandleScope handles(CcTest::isolate()); |
5636 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 5673 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
5637 v8::Context::Scope context_scope(context); | 5674 v8::Context::Scope context_scope(context); |
5638 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 5675 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
5639 128 * 1024); | 5676 128 * 1024); |
5640 | 5677 |
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7223 // "Array() **= 10", | 7260 // "Array() **= 10", |
7224 NULL | 7261 NULL |
7225 }; | 7262 }; |
7226 // clang-format on | 7263 // clang-format on |
7227 | 7264 |
7228 static const ParserFlag always_flags[] = { | 7265 static const ParserFlag always_flags[] = { |
7229 kAllowHarmonyExponentiationOperator}; | 7266 kAllowHarmonyExponentiationOperator}; |
7230 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7267 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7231 arraysize(always_flags)); | 7268 arraysize(always_flags)); |
7232 } | 7269 } |
OLD | NEW |