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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 termination_data[k], | 1229 termination_data[k], |
1230 context_data[i][1]); | 1230 context_data[i][1]); |
1231 CHECK(length == kProgramSize); | 1231 CHECK(length == kProgramSize); |
1232 i::Handle<i::String> source = | 1232 i::Handle<i::String> source = |
1233 FACTORY->NewStringFromAscii(i::CStrVector(program.start())); | 1233 FACTORY->NewStringFromAscii(i::CStrVector(program.start())); |
1234 TestParserSyncWithFlags(source); | 1234 TestParserSyncWithFlags(source); |
1235 } | 1235 } |
1236 } | 1236 } |
1237 } | 1237 } |
1238 } | 1238 } |
| 1239 |
| 1240 |
| 1241 TEST(PreparserStrictOctal) { |
| 1242 // Test that syntax error caused by octal literal is reported correctly as |
| 1243 // such (issue 2220). |
| 1244 v8::internal::FLAG_min_preparse_length = 1; // Force preparsing. |
| 1245 v8::V8::Initialize(); |
| 1246 v8::HandleScope scope; |
| 1247 v8::Context::Scope context_scope(v8::Context::New()); |
| 1248 v8::TryCatch try_catch; |
| 1249 const char* script = |
| 1250 "\"use strict\"; \n" |
| 1251 "a = function() { \n" |
| 1252 " b = function() { \n" |
| 1253 " 01; \n" |
| 1254 " }; \n" |
| 1255 "}; \n"; |
| 1256 v8::Script::Compile(v8::String::New(script)); |
| 1257 CHECK(try_catch.HasCaught()); |
| 1258 v8::String::Utf8Value exception(try_catch.Exception()); |
| 1259 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
| 1260 *exception); |
| 1261 } |
OLD | NEW |