| 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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 // parts of the source that belong to the global scope. | 873 // parts of the source that belong to the global scope. |
| 874 struct SourceData { | 874 struct SourceData { |
| 875 const char* outer_prefix; | 875 const char* outer_prefix; |
| 876 const char* inner_source; | 876 const char* inner_source; |
| 877 const char* outer_suffix; | 877 const char* outer_suffix; |
| 878 i::ScopeType scope_type; | 878 i::ScopeType scope_type; |
| 879 i::LanguageMode language_mode; | 879 i::LanguageMode language_mode; |
| 880 }; | 880 }; |
| 881 | 881 |
| 882 const SourceData source_data[] = { | 882 const SourceData source_data[] = { |
| 883 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 883 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 884 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 884 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 885 { " with ({}) ", "{\n" | 885 { " with ({}) ", "{\n" |
| 886 " block;\n" | 886 " block;\n" |
| 887 " }", "\n" | 887 " }", "\n" |
| 888 " more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 888 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 889 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 889 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 890 { " with ({}) ", "statement", "\n" | 890 { " with ({}) ", "statement", "\n" |
| 891 " more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 891 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 892 { " with ({})\n" | 892 { " with ({})\n" |
| 893 " ", "statement;", "\n" | 893 " ", "statement;", "\n" |
| 894 " more;", i::WITH_SCOPE, i::CLASSIC_MODE }, | 894 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, |
| 895 { " try {} catch ", "(e) { block; }", " more;", | 895 { " try {} catch ", "(e) { block; }", " more;", |
| 896 i::CATCH_SCOPE, i::CLASSIC_MODE }, | 896 i::CATCH_SCOPE, i::SLOPPY_MODE }, |
| 897 { " try {} catch ", "(e) { block; }", "; more;", | 897 { " try {} catch ", "(e) { block; }", "; more;", |
| 898 i::CATCH_SCOPE, i::CLASSIC_MODE }, | 898 i::CATCH_SCOPE, i::SLOPPY_MODE }, |
| 899 { " try {} catch ", "(e) {\n" | 899 { " try {} catch ", "(e) {\n" |
| 900 " block;\n" | 900 " block;\n" |
| 901 " }", "\n" | 901 " }", "\n" |
| 902 " more;", i::CATCH_SCOPE, i::CLASSIC_MODE }, | 902 " more;", i::CATCH_SCOPE, i::SLOPPY_MODE }, |
| 903 { " try {} catch ", "(e) { block; }", " finally { block; } more;", | 903 { " try {} catch ", "(e) { block; }", " finally { block; } more;", |
| 904 i::CATCH_SCOPE, i::CLASSIC_MODE }, | 904 i::CATCH_SCOPE, i::SLOPPY_MODE }, |
| 905 { " start;\n" | 905 { " start;\n" |
| 906 " ", "{ let block; }", " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 906 " ", "{ let block; }", " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 907 { " start;\n" | 907 { " start;\n" |
| 908 " ", "{ let block; }", "; more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 908 " ", "{ let block; }", "; more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 909 { " start;\n" | 909 { " start;\n" |
| 910 " ", "{\n" | 910 " ", "{\n" |
| 911 " let block;\n" | 911 " let block;\n" |
| 912 " }", "\n" | 912 " }", "\n" |
| 913 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 913 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 914 { " start;\n" | 914 { " start;\n" |
| 915 " function fun", "(a,b) { infunction; }", " more;", | 915 " function fun", "(a,b) { infunction; }", " more;", |
| 916 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 916 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 917 { " start;\n" | 917 { " start;\n" |
| 918 " function fun", "(a,b) {\n" | 918 " function fun", "(a,b) {\n" |
| 919 " infunction;\n" | 919 " infunction;\n" |
| 920 " }", "\n" | 920 " }", "\n" |
| 921 " more;", i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 921 " more;", i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 922 { " (function fun", "(a,b) { infunction; }", ")();", | 922 { " (function fun", "(a,b) { infunction; }", ")();", |
| 923 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 923 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 924 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;", | 924 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;", |
| 925 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 925 i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 926 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;", | 926 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;", |
| 927 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 927 i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 928 { " for ", "(let x = 1 ; x < 10; ++ x) {\n" | 928 { " for ", "(let x = 1 ; x < 10; ++ x) {\n" |
| 929 " block;\n" | 929 " block;\n" |
| 930 " }", "\n" | 930 " }", "\n" |
| 931 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 931 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 932 { " for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;", | 932 { " for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;", |
| 933 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 933 i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 949 { " for ", "(let x in {}) statement", "\n" | 949 { " for ", "(let x in {}) statement", "\n" |
| 950 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 950 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 951 { " for ", "(let x in {})\n" | 951 { " for ", "(let x in {})\n" |
| 952 " statement;", "\n" | 952 " statement;", "\n" |
| 953 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 953 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, |
| 954 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw | 954 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw |
| 955 // the preparser off in terms of byte offsets. | 955 // the preparser off in terms of byte offsets. |
| 956 // 6 byte encoding. | 956 // 6 byte encoding. |
| 957 { " 'foo\355\240\201\355\260\211';\n" | 957 { " 'foo\355\240\201\355\260\211';\n" |
| 958 " (function fun", "(a,b) { infunction; }", ")();", | 958 " (function fun", "(a,b) { infunction; }", ")();", |
| 959 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 959 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 960 // 4 byte encoding. | 960 // 4 byte encoding. |
| 961 { " 'foo\360\220\220\212';\n" | 961 { " 'foo\360\220\220\212';\n" |
| 962 " (function fun", "(a,b) { infunction; }", ")();", | 962 " (function fun", "(a,b) { infunction; }", ")();", |
| 963 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 963 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 964 // 3 byte encoding of \u0fff. | 964 // 3 byte encoding of \u0fff. |
| 965 { " 'foo\340\277\277';\n" | 965 { " 'foo\340\277\277';\n" |
| 966 " (function fun", "(a,b) { infunction; }", ")();", | 966 " (function fun", "(a,b) { infunction; }", ")();", |
| 967 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 967 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 968 // Broken 6 byte encoding with missing last byte. | 968 // Broken 6 byte encoding with missing last byte. |
| 969 { " 'foo\355\240\201\355\211';\n" | 969 { " 'foo\355\240\201\355\211';\n" |
| 970 " (function fun", "(a,b) { infunction; }", ")();", | 970 " (function fun", "(a,b) { infunction; }", ")();", |
| 971 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 971 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 972 // Broken 3 byte encoding of \u0fff with missing last byte. | 972 // Broken 3 byte encoding of \u0fff with missing last byte. |
| 973 { " 'foo\340\277';\n" | 973 { " 'foo\340\277';\n" |
| 974 " (function fun", "(a,b) { infunction; }", ")();", | 974 " (function fun", "(a,b) { infunction; }", ")();", |
| 975 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 975 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 976 // Broken 3 byte encoding of \u0fff with missing 2 last bytes. | 976 // Broken 3 byte encoding of \u0fff with missing 2 last bytes. |
| 977 { " 'foo\340';\n" | 977 { " 'foo\340';\n" |
| 978 " (function fun", "(a,b) { infunction; }", ")();", | 978 " (function fun", "(a,b) { infunction; }", ")();", |
| 979 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 979 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 980 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding. | 980 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding. |
| 981 { " 'foo\340\203\277';\n" | 981 { " 'foo\340\203\277';\n" |
| 982 " (function fun", "(a,b) { infunction; }", ")();", | 982 " (function fun", "(a,b) { infunction; }", ")();", |
| 983 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 983 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 984 // Broken 3 byte encoding of \u007f should be a 2 byte encoding. | 984 // Broken 3 byte encoding of \u007f should be a 2 byte encoding. |
| 985 { " 'foo\340\201\277';\n" | 985 { " 'foo\340\201\277';\n" |
| 986 " (function fun", "(a,b) { infunction; }", ")();", | 986 " (function fun", "(a,b) { infunction; }", ")();", |
| 987 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 987 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 988 // Unpaired lead surrogate. | 988 // Unpaired lead surrogate. |
| 989 { " 'foo\355\240\201';\n" | 989 { " 'foo\355\240\201';\n" |
| 990 " (function fun", "(a,b) { infunction; }", ")();", | 990 " (function fun", "(a,b) { infunction; }", ")();", |
| 991 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 991 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 992 // Unpaired lead surrogate where following code point is a 3 byte sequence. | 992 // Unpaired lead surrogate where following code point is a 3 byte sequence. |
| 993 { " 'foo\355\240\201\340\277\277';\n" | 993 { " 'foo\355\240\201\340\277\277';\n" |
| 994 " (function fun", "(a,b) { infunction; }", ")();", | 994 " (function fun", "(a,b) { infunction; }", ")();", |
| 995 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 995 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 996 // Unpaired lead surrogate where following code point is a 4 byte encoding | 996 // Unpaired lead surrogate where following code point is a 4 byte encoding |
| 997 // of a trail surrogate. | 997 // of a trail surrogate. |
| 998 { " 'foo\355\240\201\360\215\260\211';\n" | 998 { " 'foo\355\240\201\360\215\260\211';\n" |
| 999 " (function fun", "(a,b) { infunction; }", ")();", | 999 " (function fun", "(a,b) { infunction; }", ")();", |
| 1000 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1000 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1001 // Unpaired trail surrogate. | 1001 // Unpaired trail surrogate. |
| 1002 { " 'foo\355\260\211';\n" | 1002 { " 'foo\355\260\211';\n" |
| 1003 " (function fun", "(a,b) { infunction; }", ")();", | 1003 " (function fun", "(a,b) { infunction; }", ")();", |
| 1004 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1004 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1005 // 2 byte encoding of \u00ff. | 1005 // 2 byte encoding of \u00ff. |
| 1006 { " 'foo\303\277';\n" | 1006 { " 'foo\303\277';\n" |
| 1007 " (function fun", "(a,b) { infunction; }", ")();", | 1007 " (function fun", "(a,b) { infunction; }", ")();", |
| 1008 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1008 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1009 // Broken 2 byte encoding of \u00ff with missing last byte. | 1009 // Broken 2 byte encoding of \u00ff with missing last byte. |
| 1010 { " 'foo\303';\n" | 1010 { " 'foo\303';\n" |
| 1011 " (function fun", "(a,b) { infunction; }", ")();", | 1011 " (function fun", "(a,b) { infunction; }", ")();", |
| 1012 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1012 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1013 // Broken 2 byte encoding of \u007f should be a 1 byte encoding. | 1013 // Broken 2 byte encoding of \u007f should be a 1 byte encoding. |
| 1014 { " 'foo\301\277';\n" | 1014 { " 'foo\301\277';\n" |
| 1015 " (function fun", "(a,b) { infunction; }", ")();", | 1015 " (function fun", "(a,b) { infunction; }", ")();", |
| 1016 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1016 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1017 // Illegal 5 byte encoding. | 1017 // Illegal 5 byte encoding. |
| 1018 { " 'foo\370\277\277\277\277';\n" | 1018 { " 'foo\370\277\277\277\277';\n" |
| 1019 " (function fun", "(a,b) { infunction; }", ")();", | 1019 " (function fun", "(a,b) { infunction; }", ")();", |
| 1020 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1020 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1021 // Illegal 6 byte encoding. | 1021 // Illegal 6 byte encoding. |
| 1022 { " 'foo\374\277\277\277\277\277';\n" | 1022 { " 'foo\374\277\277\277\277\277';\n" |
| 1023 " (function fun", "(a,b) { infunction; }", ")();", | 1023 " (function fun", "(a,b) { infunction; }", ")();", |
| 1024 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1024 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1025 // Illegal 0xfe byte | 1025 // Illegal 0xfe byte |
| 1026 { " 'foo\376\277\277\277\277\277\277';\n" | 1026 { " 'foo\376\277\277\277\277\277\277';\n" |
| 1027 " (function fun", "(a,b) { infunction; }", ")();", | 1027 " (function fun", "(a,b) { infunction; }", ")();", |
| 1028 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1028 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1029 // Illegal 0xff byte | 1029 // Illegal 0xff byte |
| 1030 { " 'foo\377\277\277\277\277\277\277\277';\n" | 1030 { " 'foo\377\277\277\277\277\277\277\277';\n" |
| 1031 " (function fun", "(a,b) { infunction; }", ")();", | 1031 " (function fun", "(a,b) { infunction; }", ")();", |
| 1032 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1032 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1033 { " 'foo';\n" | 1033 { " 'foo';\n" |
| 1034 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", | 1034 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", |
| 1035 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1035 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1036 { " 'foo';\n" | 1036 { " 'foo';\n" |
| 1037 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", | 1037 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", |
| 1038 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, | 1038 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, |
| 1039 { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE } | 1039 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY_MODE } |
| 1040 }; | 1040 }; |
| 1041 | 1041 |
| 1042 i::Isolate* isolate = CcTest::i_isolate(); | 1042 i::Isolate* isolate = CcTest::i_isolate(); |
| 1043 i::Factory* factory = isolate->factory(); | 1043 i::Factory* factory = isolate->factory(); |
| 1044 | 1044 |
| 1045 v8::HandleScope handles(CcTest::isolate()); | 1045 v8::HandleScope handles(CcTest::isolate()); |
| 1046 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1046 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 1047 v8::Context::Scope context_scope(context); | 1047 v8::Context::Scope context_scope(context); |
| 1048 | 1048 |
| 1049 int marker; | 1049 int marker; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 i::Factory* factory = isolate->factory(); | 1101 i::Factory* factory = isolate->factory(); |
| 1102 const char* message = data->BuildMessage(); | 1102 const char* message = data->BuildMessage(); |
| 1103 i::Handle<i::String> format = v8::Utils::OpenHandle( | 1103 i::Handle<i::String> format = v8::Utils::OpenHandle( |
| 1104 *v8::String::NewFromUtf8(CcTest::isolate(), message)); | 1104 *v8::String::NewFromUtf8(CcTest::isolate(), message)); |
| 1105 i::Vector<const char*> args = data->BuildArgs(); | 1105 i::Vector<const char*> args = data->BuildArgs(); |
| 1106 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); | 1106 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); |
| 1107 for (int i = 0; i < args.length(); i++) { | 1107 for (int i = 0; i < args.length(); i++) { |
| 1108 i::JSArray::SetElement( | 1108 i::JSArray::SetElement( |
| 1109 args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8( | 1109 args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8( |
| 1110 CcTest::isolate(), args[i])), | 1110 CcTest::isolate(), args[i])), |
| 1111 NONE, i::kNonStrictMode); | 1111 NONE, i::kSloppyMode); |
| 1112 } | 1112 } |
| 1113 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); | 1113 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); |
| 1114 i::Handle<i::Object> format_fun = | 1114 i::Handle<i::Object> format_fun = |
| 1115 i::GetProperty(builtins, "FormatMessage"); | 1115 i::GetProperty(builtins, "FormatMessage"); |
| 1116 i::Handle<i::Object> arg_handles[] = { format, args_array }; | 1116 i::Handle<i::Object> arg_handles[] = { format, args_array }; |
| 1117 bool has_exception = false; | 1117 bool has_exception = false; |
| 1118 i::Handle<i::Object> result = i::Execution::Call( | 1118 i::Handle<i::Object> result = i::Execution::Call( |
| 1119 isolate, format_fun, builtins, 2, arg_handles, &has_exception); | 1119 isolate, format_fun, builtins, 2, arg_handles, &has_exception); |
| 1120 CHECK(!has_exception); | 1120 CHECK(!has_exception); |
| 1121 CHECK(result->IsString()); | 1121 CHECK(result->IsString()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 "++arguments;", | 1486 "++arguments;", |
| 1487 "eval++;", | 1487 "eval++;", |
| 1488 "arguments++;", | 1488 "arguments++;", |
| 1489 NULL | 1489 NULL |
| 1490 }; | 1490 }; |
| 1491 | 1491 |
| 1492 RunParserSyncTest(context_data, statement_data, kError); | 1492 RunParserSyncTest(context_data, statement_data, kError); |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 | 1495 |
| 1496 TEST(NoErrorsEvalAndArgumentsClassic) { | 1496 TEST(NoErrorsEvalAndArgumentsSloppy) { |
| 1497 // Tests that both preparsing and parsing accept "eval" and "arguments" as | 1497 // Tests that both preparsing and parsing accept "eval" and "arguments" as |
| 1498 // identifiers when needed. | 1498 // identifiers when needed. |
| 1499 const char* context_data[][2] = { | 1499 const char* context_data[][2] = { |
| 1500 { "", "" }, | 1500 { "", "" }, |
| 1501 { "function test_func() {", "}"}, | 1501 { "function test_func() {", "}"}, |
| 1502 { NULL, NULL } | 1502 { NULL, NULL } |
| 1503 }; | 1503 }; |
| 1504 | 1504 |
| 1505 const char* statement_data[] = { | 1505 const char* statement_data[] = { |
| 1506 "var eval;", | 1506 "var eval;", |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 "++super;", | 1631 "++super;", |
| 1632 "super++;", | 1632 "super++;", |
| 1633 "function foo super", | 1633 "function foo super", |
| 1634 NULL | 1634 NULL |
| 1635 }; | 1635 }; |
| 1636 | 1636 |
| 1637 RunParserSyncTest(context_data, statement_data, kError); | 1637 RunParserSyncTest(context_data, statement_data, kError); |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 | 1640 |
| 1641 TEST(NoErrorsYieldClassic) { | 1641 TEST(NoErrorsYieldSloppy) { |
| 1642 // In classic mode, it's okay to use "yield" as identifier, *except* inside a | 1642 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a |
| 1643 // generator (see next test). | 1643 // generator (see next test). |
| 1644 const char* context_data[][2] = { | 1644 const char* context_data[][2] = { |
| 1645 { "", "" }, | 1645 { "", "" }, |
| 1646 { "function is_not_gen() {", "}" }, | 1646 { "function is_not_gen() {", "}" }, |
| 1647 { NULL, NULL } | 1647 { NULL, NULL } |
| 1648 }; | 1648 }; |
| 1649 | 1649 |
| 1650 const char* statement_data[] = { | 1650 const char* statement_data[] = { |
| 1651 "var yield;", | 1651 "var yield;", |
| 1652 "var foo, yield;", | 1652 "var foo, yield;", |
| 1653 "try { } catch (yield) { }", | 1653 "try { } catch (yield) { }", |
| 1654 "function yield() { }", | 1654 "function yield() { }", |
| 1655 "function foo(yield) { }", | 1655 "function foo(yield) { }", |
| 1656 "function foo(bar, yield) { }", | 1656 "function foo(bar, yield) { }", |
| 1657 "yield = 1;", | 1657 "yield = 1;", |
| 1658 "var foo = yield = 1;", | 1658 "var foo = yield = 1;", |
| 1659 "++yield;", | 1659 "++yield;", |
| 1660 "yield++;", | 1660 "yield++;", |
| 1661 NULL | 1661 NULL |
| 1662 }; | 1662 }; |
| 1663 | 1663 |
| 1664 RunParserSyncTest(context_data, statement_data, kSuccess); | 1664 RunParserSyncTest(context_data, statement_data, kSuccess); |
| 1665 } | 1665 } |
| 1666 | 1666 |
| 1667 | 1667 |
| 1668 TEST(ErrorsYieldClassicGenerator) { | 1668 TEST(ErrorsYieldSloppyGenerator) { |
| 1669 const char* context_data[][2] = { | 1669 const char* context_data[][2] = { |
| 1670 { "function * is_gen() {", "}" }, | 1670 { "function * is_gen() {", "}" }, |
| 1671 { NULL, NULL } | 1671 { NULL, NULL } |
| 1672 }; | 1672 }; |
| 1673 | 1673 |
| 1674 const char* statement_data[] = { | 1674 const char* statement_data[] = { |
| 1675 "var yield;", | 1675 "var yield;", |
| 1676 "var foo, yield;", | 1676 "var foo, yield;", |
| 1677 "try { } catch (yield) { }", | 1677 "try { } catch (yield) { }", |
| 1678 "function yield() { }", | 1678 "function yield() { }", |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 "function interface() { }", | 1774 "function interface() { }", |
| 1775 "function yield() { }", | 1775 "function yield() { }", |
| 1776 NULL | 1776 NULL |
| 1777 }; | 1777 }; |
| 1778 | 1778 |
| 1779 RunParserSyncTest(context_data, statement_data, kSuccess); | 1779 RunParserSyncTest(context_data, statement_data, kSuccess); |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 | 1782 |
| 1783 | 1783 |
| 1784 TEST(ErrorsIllegalWordsAsLabelsClassic) { | 1784 TEST(ErrorsIllegalWordsAsLabelsSloppy) { |
| 1785 // Using future reserved words as labels is always an error. | 1785 // Using future reserved words as labels is always an error. |
| 1786 const char* context_data[][2] = { | 1786 const char* context_data[][2] = { |
| 1787 { "", ""}, | 1787 { "", ""}, |
| 1788 { "function test_func() {", "}" }, | 1788 { "function test_func() {", "}" }, |
| 1789 { NULL, NULL } | 1789 { NULL, NULL } |
| 1790 }; | 1790 }; |
| 1791 | 1791 |
| 1792 const char* statement_data[] = { | 1792 const char* statement_data[] = { |
| 1793 "super: while(true) { break super; }", | 1793 "super: while(true) { break super; }", |
| 1794 NULL | 1794 NULL |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 | 2151 |
| 2152 const char* statement_data[] = { | 2152 const char* statement_data[] = { |
| 2153 "new foo bar", | 2153 "new foo bar", |
| 2154 "new ) foo", | 2154 "new ) foo", |
| 2155 "new ++foo", | 2155 "new ++foo", |
| 2156 NULL | 2156 NULL |
| 2157 }; | 2157 }; |
| 2158 | 2158 |
| 2159 RunParserSyncTest(context_data, statement_data, kError); | 2159 RunParserSyncTest(context_data, statement_data, kError); |
| 2160 } | 2160 } |
| OLD | NEW |