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 24 Tests 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 26 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 27 28 29 PASS /\x{41}/.exec("yA1") is null 30 PASS /[\x{41}]/.exec("yA1").toString() is "1" 31 PASS /\x1g/.exec("x1g").toString() is "x1g" 32 PASS /[\x1g]/.exec("x").toString() is "x" 33 PASS /[\x1g]/.exec("1").toString() is "1" 34 PASS /\2147483648/.exec(String.fromCharCode(140) + "7483648").toString() is String.fromCharCode(140) + "7483648" 35 PASS /\4294967296/.exec("\"94967296").toString() is "\"94967296" 36 FAIL /\8589934592/.exec("\\8589934592").toString() should be \8589934592. Was 8589934592. 37 PASS "\nAbc\n".replace(/(\n)[^\n]+$/, "$1") is "\nAbc\n" 38 PASS /x$/.exec("x\n") is null 39 PASS /x++/ threw exception SyntaxError: Invalid regular expression: /x++/: Nothing to repeat. 40 PASS /[]]/.exec("]") is null 41 42 Octal escape sequences are in Annex B of the standard. 43 44 PASS /\060/.exec("y01").toString() is "0" 45 PASS /[\060]/.exec("y01").toString() is "0" 46 PASS /\606/.exec("y06").toString() is "06" 47 PASS /[\606]/.exec("y06").toString() is "0" 48 PASS /[\606]/.exec("y6").toString() is "6" 49 PASS /\101/.exec("yA1").toString() is "A" 50 PASS /[\101]/.exec("yA1").toString() is "A" 51 PASS /\1011/.exec("yA1").toString() is "A1" 52 PASS /[\1011]/.exec("yA1").toString() is "A" 53 PASS /[\1011]/.exec("y1").toString() is "1" 54 PASS /\10q/.exec("y" + String.fromCharCode(8) + "q").toString() is String.fromCharCode(8) + "q" 55 PASS /[\10q]/.exec("y" + String.fromCharCode(8) + "q").toString() is String.fromCharCode(8) 56 PASS /\1q/.exec("y" + String.fromCharCode(1) + "q").toString() is String.fromCharCode(1) + "q" 57 PASS /[\1q]/.exec("y" + String.fromCharCode(1) + "q").toString() is String.fromCharCode(1) 58 PASS /[\1q]/.exec("yq").toString() is "q" 59 FAIL /\8q/.exec("\\8q").toString() should be \8q. Was 8q. 60 PASS /[\8q]/.exec("y8q").toString() is "8" 61 PASS /[\8q]/.exec("yq").toString() is "q" 62 PASS /(x)\1q/.exec("xxq").toString() is "xxq,x" 63 PASS /(x)[\1q]/.exec("xxq").toString() is "xq,x" 64 PASS /(x)[\1q]/.exec("xx" + String.fromCharCode(1)).toString() is "x" + String.fromCharCode(1) + ",x" 65 66 PASS successfullyParsed is true 67 68 TEST COMPLETE 69 70