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 5893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5904 arraysize(always_flags)); | 5904 arraysize(always_flags)); |
5905 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 5905 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, |
5906 arraysize(always_flags)); | 5906 arraysize(always_flags)); |
5907 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 5907 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, |
5908 arraysize(always_flags)); | 5908 arraysize(always_flags)); |
5909 RunParserSyncTest(sloppy_context_data, local_strong, kError, NULL, 0, | 5909 RunParserSyncTest(sloppy_context_data, local_strong, kError, NULL, 0, |
5910 always_flags, arraysize(always_flags)); | 5910 always_flags, arraysize(always_flags)); |
5911 } | 5911 } |
5912 | 5912 |
5913 | 5913 |
5914 TEST(StrongDirectEval) { | |
5915 const char* context_data[][2] = {{"", ""}, {NULL}}; | |
5916 | |
5917 const char* error_data[] = { | |
5918 "'use strong'; eval();", | |
5919 "'use strong'; eval([]);", | |
5920 "'use strong'; (eval)();", | |
5921 "'use strong'; (((eval)))();", | |
5922 "'use strong'; eval('function f() {}');", | |
5923 "'use strong'; function f() {eval()}", | |
marja
2015/04/13 19:13:07
For this kind of a test, it would be useful to put
| |
5924 NULL}; | |
5925 | |
5926 const char* success_data[] = { | |
5927 "'use strong'; eval;", | |
5928 "'use strong'; eval`foo`;", | |
5929 "'use strong'; let foo = eval; foo();", | |
5930 "'use strong'; (1, eval)();", | |
5931 NULL}; | |
5932 | |
5933 static const ParserFlag always_flags[] = { | |
5934 kAllowStrongMode | |
5935 }; | |
5936 | |
5937 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | |
5938 always_flags, arraysize(always_flags)); | |
5939 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, | |
5940 always_flags, arraysize(always_flags)); | |
5941 } | |
5942 | |
5943 | |
5914 TEST(ArrowFunctionASIErrors) { | 5944 TEST(ArrowFunctionASIErrors) { |
5915 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, | 5945 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, |
5916 {NULL, NULL}}; | 5946 {NULL, NULL}}; |
5917 | 5947 |
5918 const char* data[] = { | 5948 const char* data[] = { |
5919 "(a\n=> a)(1)", | 5949 "(a\n=> a)(1)", |
5920 "(a/*\n*/=> a)(1)", | 5950 "(a/*\n*/=> a)(1)", |
5921 "((a)\n=> a)(1)", | 5951 "((a)\n=> a)(1)", |
5922 "((a)/*\n*/=> a)(1)", | 5952 "((a)/*\n*/=> a)(1)", |
5923 "((a, b)\n=> a + b)(1, 2)", | 5953 "((a, b)\n=> a + b)(1, 2)", |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6070 v8::Script::Compile(v8_str(script3)); | 6100 v8::Script::Compile(v8_str(script3)); |
6071 CHECK(try_catch2.HasCaught()); | 6101 CHECK(try_catch2.HasCaught()); |
6072 v8::String::Utf8Value exception(try_catch2.Exception()); | 6102 v8::String::Utf8Value exception(try_catch2.Exception()); |
6073 CHECK_EQ(0, | 6103 CHECK_EQ(0, |
6074 strcmp( | 6104 strcmp( |
6075 "ReferenceError: In strong mode, using an undeclared global " | 6105 "ReferenceError: In strong mode, using an undeclared global " |
6076 "variable 'not_there3' is not allowed", | 6106 "variable 'not_there3' is not allowed", |
6077 *exception)); | 6107 *exception)); |
6078 } | 6108 } |
6079 } | 6109 } |
OLD | NEW |