• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 the V8 project authors. All rights reserved.
2# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7# 1.  Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9# 2.  Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#
13# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
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 ANY
17# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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 ON
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
22# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24Tests that regular expressions do not have extensions that diverge from the JavaScript specification. Because WebKit originally used a copy of PCRE, various non-JavaScript regular expression features were historically present. Also tests various related edge cases.
25
26On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
27
28
29PASS /\x{41}/.exec("yA1") is null
30PASS /[\x{41}]/.exec("yA1").toString() is "1"
31PASS /\x1g/.exec("x1g").toString() is "x1g"
32PASS /[\x1g]/.exec("x").toString() is "x"
33PASS /[\x1g]/.exec("1").toString() is "1"
34PASS /\2147483648/.exec(String.fromCharCode(140) + "7483648").toString() is String.fromCharCode(140) + "7483648"
35PASS /\4294967296/.exec("\"94967296").toString() is "\"94967296"
36FAIL /\8589934592/.exec("\\8589934592").toString() should be \8589934592. Was 8589934592.
37PASS "\nAbc\n".replace(/(\n)[^\n]+$/, "$1") is "\nAbc\n"
38PASS /x$/.exec("x\n") is null
39PASS /x++/ threw exception SyntaxError: Invalid regular expression: /x++/: Nothing to repeat.
40PASS /[]]/.exec("]") is null
41
42Octal escape sequences are in Annex B of the standard.
43
44PASS /\060/.exec("y01").toString() is "0"
45PASS /[\060]/.exec("y01").toString() is "0"
46PASS /\606/.exec("y06").toString() is "06"
47PASS /[\606]/.exec("y06").toString() is "0"
48PASS /[\606]/.exec("y6").toString() is "6"
49PASS /\101/.exec("yA1").toString() is "A"
50PASS /[\101]/.exec("yA1").toString() is "A"
51PASS /\1011/.exec("yA1").toString() is "A1"
52PASS /[\1011]/.exec("yA1").toString() is "A"
53PASS /[\1011]/.exec("y1").toString() is "1"
54PASS /\10q/.exec("y" + String.fromCharCode(8) + "q").toString() is String.fromCharCode(8) + "q"
55PASS /[\10q]/.exec("y" + String.fromCharCode(8) + "q").toString() is String.fromCharCode(8)
56PASS /\1q/.exec("y" + String.fromCharCode(1) + "q").toString() is String.fromCharCode(1) + "q"
57PASS /[\1q]/.exec("y" + String.fromCharCode(1) + "q").toString() is String.fromCharCode(1)
58PASS /[\1q]/.exec("yq").toString() is "q"
59FAIL /\8q/.exec("\\8q").toString() should be \8q. Was 8q.
60PASS /[\8q]/.exec("y8q").toString() is "8"
61PASS /[\8q]/.exec("yq").toString() is "q"
62PASS /(x)\1q/.exec("xxq").toString() is "xxq,x"
63PASS /(x)[\1q]/.exec("xxq").toString() is "xq,x"
64PASS /(x)[\1q]/.exec("xx" + String.fromCharCode(1)).toString() is "x" + String.fromCharCode(1) + ",x"
65
66PASS successfullyParsed is true
67
68TEST COMPLETE
69
70