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 5940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5951 i::FunctionLiteral* func = info.literal(); | 5951 i::FunctionLiteral* func = info.literal(); |
5952 i::DeclarationScope* module_scope = func->scope(); | 5952 i::DeclarationScope* module_scope = func->scope(); |
5953 i::Scope* outer_scope = module_scope->outer_scope(); | 5953 i::Scope* outer_scope = module_scope->outer_scope(); |
5954 CHECK(outer_scope->is_script_scope()); | 5954 CHECK(outer_scope->is_script_scope()); |
5955 CHECK_NULL(outer_scope->outer_scope()); | 5955 CHECK_NULL(outer_scope->outer_scope()); |
5956 CHECK(module_scope->is_module_scope()); | 5956 CHECK(module_scope->is_module_scope()); |
5957 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); | 5957 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); |
5958 | 5958 |
5959 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); | 5959 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); |
5960 CHECK(declarations->at(0)->proxy()->var()->mode() == i::LET); | 5960 CHECK(declarations->at(0)->proxy()->var()->mode() == i::LET); |
| 5961 CHECK(declarations->at(0)->proxy()->var()->binding_needs_init()); |
5961 CHECK(declarations->at(0)->proxy()->var()->location() == | 5962 CHECK(declarations->at(0)->proxy()->var()->location() == |
5962 i::VariableLocation::MODULE); | 5963 i::VariableLocation::MODULE); |
5963 | 5964 |
5964 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); | 5965 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); |
5965 CHECK(declarations->at(1)->proxy()->var()->mode() == i::CONST); | 5966 CHECK(declarations->at(1)->proxy()->var()->mode() == i::CONST); |
| 5967 CHECK(declarations->at(1)->proxy()->var()->binding_needs_init()); |
5966 CHECK(declarations->at(1)->proxy()->var()->location() == | 5968 CHECK(declarations->at(1)->proxy()->var()->location() == |
5967 i::VariableLocation::MODULE); | 5969 i::VariableLocation::MODULE); |
5968 | 5970 |
5969 CHECK(declarations->at(2)->proxy()->raw_name()->IsOneByteEqualTo("n")); | 5971 CHECK(declarations->at(2)->proxy()->raw_name()->IsOneByteEqualTo("n")); |
5970 CHECK(declarations->at(2)->proxy()->var()->mode() == i::CONST); | 5972 CHECK(declarations->at(2)->proxy()->var()->mode() == i::CONST); |
| 5973 CHECK(declarations->at(2)->proxy()->var()->binding_needs_init()); |
5971 CHECK(declarations->at(2)->proxy()->var()->location() == | 5974 CHECK(declarations->at(2)->proxy()->var()->location() == |
5972 i::VariableLocation::MODULE); | 5975 i::VariableLocation::MODULE); |
5973 | 5976 |
5974 CHECK(declarations->at(3)->proxy()->raw_name()->IsOneByteEqualTo("foo")); | 5977 CHECK(declarations->at(3)->proxy()->raw_name()->IsOneByteEqualTo("foo")); |
5975 CHECK(declarations->at(3)->proxy()->var()->mode() == i::VAR); | 5978 CHECK(declarations->at(3)->proxy()->var()->mode() == i::VAR); |
| 5979 CHECK(!declarations->at(3)->proxy()->var()->binding_needs_init()); |
5976 CHECK(declarations->at(3)->proxy()->var()->location() == | 5980 CHECK(declarations->at(3)->proxy()->var()->location() == |
5977 i::VariableLocation::MODULE); | 5981 i::VariableLocation::MODULE); |
5978 | 5982 |
5979 CHECK(declarations->at(4)->proxy()->raw_name()->IsOneByteEqualTo("goo")); | 5983 CHECK(declarations->at(4)->proxy()->raw_name()->IsOneByteEqualTo("goo")); |
5980 CHECK(declarations->at(4)->proxy()->var()->mode() == i::LET); | 5984 CHECK(declarations->at(4)->proxy()->var()->mode() == i::LET); |
| 5985 CHECK(!declarations->at(4)->proxy()->var()->binding_needs_init()); |
5981 CHECK(declarations->at(4)->proxy()->var()->location() == | 5986 CHECK(declarations->at(4)->proxy()->var()->location() == |
5982 i::VariableLocation::MODULE); | 5987 i::VariableLocation::MODULE); |
5983 | 5988 |
5984 CHECK(declarations->at(5)->proxy()->raw_name()->IsOneByteEqualTo("hoo")); | 5989 CHECK(declarations->at(5)->proxy()->raw_name()->IsOneByteEqualTo("hoo")); |
5985 CHECK(declarations->at(5)->proxy()->var()->mode() == i::LET); | 5990 CHECK(declarations->at(5)->proxy()->var()->mode() == i::LET); |
| 5991 CHECK(declarations->at(5)->proxy()->var()->binding_needs_init()); |
5986 CHECK(declarations->at(5)->proxy()->var()->location() == | 5992 CHECK(declarations->at(5)->proxy()->var()->location() == |
5987 i::VariableLocation::MODULE); | 5993 i::VariableLocation::MODULE); |
5988 | 5994 |
5989 CHECK(declarations->at(6)->proxy()->raw_name()->IsOneByteEqualTo("joo")); | 5995 CHECK(declarations->at(6)->proxy()->raw_name()->IsOneByteEqualTo("joo")); |
5990 CHECK(declarations->at(6)->proxy()->var()->mode() == i::CONST); | 5996 CHECK(declarations->at(6)->proxy()->var()->mode() == i::CONST); |
| 5997 CHECK(declarations->at(6)->proxy()->var()->binding_needs_init()); |
5991 CHECK(declarations->at(6)->proxy()->var()->location() == | 5998 CHECK(declarations->at(6)->proxy()->var()->location() == |
5992 i::VariableLocation::MODULE); | 5999 i::VariableLocation::MODULE); |
5993 | 6000 |
5994 CHECK( | 6001 CHECK( |
5995 declarations->at(7)->proxy()->raw_name()->IsOneByteEqualTo("*default*")); | 6002 declarations->at(7)->proxy()->raw_name()->IsOneByteEqualTo("*default*")); |
5996 CHECK(declarations->at(7)->proxy()->var()->mode() == i::CONST); | 6003 CHECK(declarations->at(7)->proxy()->var()->mode() == i::CONST); |
| 6004 CHECK(declarations->at(7)->proxy()->var()->binding_needs_init()); |
5997 CHECK(declarations->at(7)->proxy()->var()->location() == | 6005 CHECK(declarations->at(7)->proxy()->var()->location() == |
5998 i::VariableLocation::MODULE); | 6006 i::VariableLocation::MODULE); |
5999 | 6007 |
6000 CHECK( | 6008 CHECK( |
6001 declarations->at(8)->proxy()->raw_name()->IsOneByteEqualTo("nonexport")); | 6009 declarations->at(8)->proxy()->raw_name()->IsOneByteEqualTo("nonexport")); |
| 6010 CHECK(declarations->at(8)->proxy()->var()->binding_needs_init()); |
6002 CHECK(declarations->at(8)->proxy()->var()->location() != | 6011 CHECK(declarations->at(8)->proxy()->var()->location() != |
6003 i::VariableLocation::MODULE); | 6012 i::VariableLocation::MODULE); |
6004 | 6013 |
6005 CHECK(declarations->at(9)->proxy()->raw_name()->IsOneByteEqualTo("mm")); | 6014 CHECK(declarations->at(9)->proxy()->raw_name()->IsOneByteEqualTo("mm")); |
6006 CHECK(declarations->at(9)->proxy()->var()->mode() == i::CONST); | 6015 CHECK(declarations->at(9)->proxy()->var()->mode() == i::CONST); |
| 6016 CHECK(declarations->at(9)->proxy()->var()->binding_needs_init()); |
6007 CHECK(declarations->at(9)->proxy()->var()->location() == | 6017 CHECK(declarations->at(9)->proxy()->var()->location() == |
6008 i::VariableLocation::MODULE); | 6018 i::VariableLocation::MODULE); |
6009 | 6019 |
6010 CHECK(declarations->at(10)->proxy()->raw_name()->IsOneByteEqualTo("aa")); | 6020 CHECK(declarations->at(10)->proxy()->raw_name()->IsOneByteEqualTo("aa")); |
6011 CHECK(declarations->at(10)->proxy()->var()->mode() == i::CONST); | 6021 CHECK(declarations->at(10)->proxy()->var()->mode() == i::CONST); |
| 6022 CHECK(declarations->at(10)->proxy()->var()->binding_needs_init()); |
6012 CHECK(declarations->at(10)->proxy()->var()->location() == | 6023 CHECK(declarations->at(10)->proxy()->var()->location() == |
6013 i::VariableLocation::MODULE); | 6024 i::VariableLocation::MODULE); |
6014 | 6025 |
6015 CHECK(declarations->at(11)->proxy()->raw_name()->IsOneByteEqualTo("loo")); | 6026 CHECK(declarations->at(11)->proxy()->raw_name()->IsOneByteEqualTo("loo")); |
6016 CHECK(declarations->at(11)->proxy()->var()->mode() == i::CONST); | 6027 CHECK(declarations->at(11)->proxy()->var()->mode() == i::CONST); |
| 6028 CHECK(!declarations->at(11)->proxy()->var()->binding_needs_init()); |
6017 CHECK(declarations->at(11)->proxy()->var()->location() != | 6029 CHECK(declarations->at(11)->proxy()->var()->location() != |
6018 i::VariableLocation::MODULE); | 6030 i::VariableLocation::MODULE); |
6019 | 6031 |
6020 CHECK(declarations->at(12)->proxy()->raw_name()->IsOneByteEqualTo("foob")); | 6032 CHECK(declarations->at(12)->proxy()->raw_name()->IsOneByteEqualTo("foob")); |
6021 CHECK(declarations->at(12)->proxy()->var()->mode() == i::CONST); | 6033 CHECK(declarations->at(12)->proxy()->var()->mode() == i::CONST); |
| 6034 CHECK(!declarations->at(12)->proxy()->var()->binding_needs_init()); |
6022 CHECK(declarations->at(12)->proxy()->var()->location() == | 6035 CHECK(declarations->at(12)->proxy()->var()->location() == |
6023 i::VariableLocation::MODULE); | 6036 i::VariableLocation::MODULE); |
6024 | 6037 |
6025 CHECK_EQ(13, declarations->length()); | 6038 CHECK_EQ(13, declarations->length()); |
6026 | 6039 |
6027 i::ModuleDescriptor* descriptor = module_scope->module(); | 6040 i::ModuleDescriptor* descriptor = module_scope->module(); |
6028 CHECK_NOT_NULL(descriptor); | 6041 CHECK_NOT_NULL(descriptor); |
6029 // TODO(neis): Test more once we can inspect the imports/exports. | 6042 // TODO(neis): Test more once we can inspect the imports/exports. |
6030 } | 6043 } |
6031 | 6044 |
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8050 "(a,);", | 8063 "(a,);", |
8051 "(a,b,c,);", | 8064 "(a,b,c,);", |
8052 NULL | 8065 NULL |
8053 }; | 8066 }; |
8054 // clang-format on | 8067 // clang-format on |
8055 | 8068 |
8056 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8069 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
8057 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8070 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
8058 arraysize(always_flags)); | 8071 arraysize(always_flags)); |
8059 } | 8072 } |
OLD | NEW |