OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
11 // documentation and/or other materials provided with the distribution. | 11 // documentation and/or other materials provided with the distribution. |
12 // | 12 // |
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | 23 |
24 description( | 24 description( |
25 "Tests that the DFG CFA is not overzealous in removing prototype structure check
s for put_by_id transitions." | 25 "Test numeric escapes in string literals - https://bugs.webkit.org/show_bug.cgi?
id=51724" |
26 ); | 26 ); |
27 | 27 |
28 function foo(a, b) | 28 function test(_stringLiteral, _nonStrictResult, _strictResult) |
29 { | 29 { |
30 a.f = b; | 30 stringLiteral = '"' + _stringLiteral + '"'; |
| 31 nonStrictResult = _nonStrictResult; |
| 32 shouldBe("eval(stringLiteral)", "nonStrictResult"); |
| 33 |
| 34 stringLiteral = '"use strict"; ' + stringLiteral; |
| 35 if (_strictResult) { |
| 36 strictResult = _strictResult; |
| 37 shouldBe("eval(stringLiteral)", "strictResult"); |
| 38 } else |
| 39 shouldThrow("eval(stringLiteral)"); |
31 } | 40 } |
32 | 41 |
33 var Empty = ""; | 42 // Tests for single digit octal and decimal escapes. |
| 43 // In non-strict mode 0-7 are octal escapes, 8-9 are NonEscapeCharacters. |
| 44 // In strict mode only "\0" is permitted. |
| 45 test("\\0", "\x00", "\x00"); |
| 46 test("\\1", "\x01"); |
| 47 test("\\7", "\x07"); |
| 48 test("\\8", "8"); |
| 49 test("\\9", "9"); |
34 | 50 |
35 function Foo() { | 51 // Tests for multi-digit octal values outside strict mode; |
36 } | 52 // Octal literals may be 1-3 digits long. In strict more all multi-digit sequen
ces are illegal. |
| 53 test("\\00", "\x00"); |
| 54 test("\\000", "\x00"); |
| 55 test("\\0000", "\x000"); |
37 | 56 |
38 var stuff; | 57 test("\\01", "\x01"); |
| 58 test("\\001", "\x01"); |
| 59 test("\\0001", "\x001"); |
39 | 60 |
40 for (var i = 0; i < 1000; ++i) { | 61 test("\\10", "\x08"); |
41 if (i >= 900) | 62 test("\\100", "\x40"); |
42 Foo.prototype.__defineSetter__("f", function(value) { stuff = value; }); | 63 test("\\1000", "\x400"); |
43 | 64 |
44 var o = new Foo(); | 65 test("\\19", "\x019"); |
45 eval(Empty + "foo(o, i)"); | 66 test("\\109", "\x089"); |
46 if (i >= 900) { | 67 test("\\1009", "\x409"); |
47 shouldBe("stuff", "" + i); | |
48 shouldBe("o.f", "" + (void 0)); | |
49 } else | |
50 shouldBe("o.f", "" + i); | |
51 } | |
52 | 68 |
| 69 test("\\99", "99"); |
OLD | NEW |