| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 #include <stdio.h> | 29 #include <stdio.h> |
| 30 #include <string.h> | 30 #include <string.h> |
| 31 | 31 |
| 32 #include "v8.h" | 32 #include "v8.h" |
| 33 | 33 |
| 34 #include "cctest.h" | 34 #include "cctest.h" |
| 35 #include "compiler.h" |
| 35 #include "execution.h" | 36 #include "execution.h" |
| 36 #include "isolate.h" | 37 #include "isolate.h" |
| 37 #include "parser.h" | 38 #include "parser.h" |
| 38 #include "preparser.h" | 39 #include "preparser.h" |
| 39 #include "scanner-character-streams.h" | 40 #include "scanner-character-streams.h" |
| 40 #include "token.h" | 41 #include "token.h" |
| 41 #include "utils.h" | 42 #include "utils.h" |
| 42 | 43 |
| 43 TEST(ScanKeywords) { | 44 TEST(ScanKeywords) { |
| 44 struct KeywordToken { | 45 struct KeywordToken { |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 source_data[i].inner_source, | 850 source_data[i].inner_source, |
| 850 source_data[i].outer_suffix); | 851 source_data[i].outer_suffix); |
| 851 CHECK(length == kProgramSize); | 852 CHECK(length == kProgramSize); |
| 852 | 853 |
| 853 // Parse program source. | 854 // Parse program source. |
| 854 i::Handle<i::String> source( | 855 i::Handle<i::String> source( |
| 855 FACTORY->NewStringFromAscii(i::CStrVector(program.start()))); | 856 FACTORY->NewStringFromAscii(i::CStrVector(program.start()))); |
| 856 i::Handle<i::Script> script = FACTORY->NewScript(source); | 857 i::Handle<i::Script> script = FACTORY->NewScript(source); |
| 857 i::Parser parser(script, false, NULL, NULL); | 858 i::Parser parser(script, false, NULL, NULL); |
| 858 parser.SetHarmonyScoping(true); | 859 parser.SetHarmonyScoping(true); |
| 859 i::FunctionLiteral* function = | 860 i::CompilationInfo info(script); |
| 860 parser.ParseProgram(source, true, i::kNonStrictMode); | 861 info.MarkAsGlobal(); |
| 861 ASSERT(function != NULL); | 862 i::FunctionLiteral* function = parser.ParseProgram(&info); |
| 863 CHECK(function != NULL); |
| 862 | 864 |
| 863 // Check scope types and positions. | 865 // Check scope types and positions. |
| 864 i::Scope* scope = function->scope(); | 866 i::Scope* scope = function->scope(); |
| 865 CHECK(scope->is_global_scope()); | 867 CHECK(scope->is_global_scope()); |
| 866 CHECK_EQ(scope->start_position(), 0); | 868 CHECK_EQ(scope->start_position(), 0); |
| 867 CHECK_EQ(scope->end_position(), kProgramSize); | 869 CHECK_EQ(scope->end_position(), kProgramSize); |
| 868 CHECK_EQ(scope->inner_scopes()->length(), 1); | 870 CHECK_EQ(scope->inner_scopes()->length(), 1); |
| 869 | 871 |
| 870 i::Scope* inner_scope = scope->inner_scopes()->at(0); | 872 i::Scope* inner_scope = scope->inner_scopes()->at(0); |
| 871 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); | 873 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); |
| 872 CHECK_EQ(inner_scope->start_position(), kPrefixLen); | 874 CHECK_EQ(inner_scope->start_position(), kPrefixLen); |
| 873 // The end position of a token is one position after the last | 875 // The end position of a token is one position after the last |
| 874 // character belonging to that token. | 876 // character belonging to that token. |
| 875 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); | 877 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); |
| 876 } | 878 } |
| 877 } | 879 } |
| OLD | NEW |