| 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 4287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4298 const char* context_data[][2] = {{"", ""}, | 4298 const char* context_data[][2] = {{"", ""}, |
| 4299 {"'use strict';", ""}, | 4299 {"'use strict';", ""}, |
| 4300 {NULL, NULL}}; | 4300 {NULL, NULL}}; |
| 4301 const char* data[] = { | 4301 const char* data[] = { |
| 4302 "var foob\\u123r = 0;", | 4302 "var foob\\u123r = 0;", |
| 4303 "var \\u123roo = 0;", | 4303 "var \\u123roo = 0;", |
| 4304 "\"foob\\u123rr\"", | 4304 "\"foob\\u123rr\"", |
| 4305 // No escapes allowed in regexp flags | 4305 // No escapes allowed in regexp flags |
| 4306 "/regex/\\u0069g", | 4306 "/regex/\\u0069g", |
| 4307 "/regex/\\u006g", | 4307 "/regex/\\u006g", |
| 4308 "/regex/\\u{0069}g", |
| 4309 "/regex/\\u{69}g", |
| 4310 "/regex/\\u{00000069}g", |
| 4311 // Braces gone wrong |
| 4312 "var foob\\u{c481r = 0;", |
| 4313 "var foob\\uc481}r = 0;", |
| 4314 "var \\u{0052oo = 0;", |
| 4315 "var \\u0052}oo = 0;", |
| 4316 "\"foob\\u{c481r\"", |
| 4308 NULL}; | 4317 NULL}; |
| 4309 RunParserSyncTest(context_data, data, kError); | 4318 RunParserSyncTest(context_data, data, kError); |
| 4310 } | 4319 } |
| 4320 |
| 4321 |
| 4322 TEST(UnicodeEscapes) { |
| 4323 const char* context_data[][2] = {{"", ""}, |
| 4324 {"'use strict';", ""}, |
| 4325 {NULL, NULL}}; |
| 4326 const char* data[] = { |
| 4327 // Identifier starting with escape |
| 4328 "var \\u0052oo = 0;", |
| 4329 "var \\u{0052}oo = 0;", |
| 4330 "var \\u{52}oo = 0;", |
| 4331 "var \\u{00000000052}oo = 0;", |
| 4332 // Identifier with an escape but not starting with an escape |
| 4333 "var foob\\uc481r = 0;", |
| 4334 "var foob\\u{c481}r = 0;", |
| 4335 // String with an escape |
| 4336 "\"foob\\uc481r\"", |
| 4337 "\"foob\\{uc481}r\"", |
| 4338 // Regexp body |
| 4339 "/(\\u0066|\\u0062)oo/", |
| 4340 "/(\\u{0066}|\\u{0062})oo/", |
| 4341 "/[\\u0062-\\u0066]oo/", |
| 4342 "/[\\u{0062}-\\u{0066}]oo/", |
| 4343 // If the { cannot be matched, the escape is only \u and the rest is |
| 4344 // not part of the escape. |
| 4345 "/(\\u{0066|\\u{0062)oo/", |
| 4346 "/[\\u{0062-\\u{0066 ]oo/", |
| 4347 // This character is a valid unicode character, representable as a surrogate |
| 4348 // pair, not representable as 4 hex digits. |
| 4349 "\"foo\\u{10e6d}\"", |
| 4350 NULL}; |
| 4351 RunParserSyncTest(context_data, data, kSuccess); |
| 4352 } |
| OLD | NEW |