Home | History | Annotate | Download | only in regex
      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 This page tests handling of parentheses subexpressions.
     25 
     26 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     27 
     28 
     29 PASS regexp1.exec('abc') is ['ab','a','b']
     30 PASS regexp2.exec('abacadabe') is ['abe','ab','b','b']
     31 PASS regexp3.exec('abacadabe') is ['abe','ab','b',undefined]
     32 PASS regexp4.exec('abacadabe') is ['abe','ab','b',undefined]
     33 PASS regexp5.exec('abacadabe') is ['abe','ab','b','b',undefined,undefined]
     34 PASS regexp6.exec('abcde') is ['ab','ab','b','b',undefined,undefined]
     35 PASS regexp7.exec('abc') is ['abc','ab','b']
     36 PASS regexp8.exec('bcaddxqy') is ['qy','q','q','y']
     37 PASS regexp9.exec('asdfjejgsdflaksdfjkeljghkjea') is ['a','a',undefined]
     38 PASS regexp10.exec('asdfjejgsdflaksdfjkeljghat') is ['at']
     39 PASS regexp11.exec('Developing with JavaScript is dangerous, do not try it without assistance') is null
     40 PASS regexp12.exec('Seattle, WA to Buckley, WA') is ['Seattle, WA to Buckley, WA', undefined, 'Seattle', 'WA', undefined, 'Buckley', 'WA']
     41 PASS regexp13.exec('zxcasd;fl ^AaaAAaaaf;lrlrzs') is ['AaaAAaaaf;lrlrzs',undefined,'AaaAAaaaf;lrlrzs']
     42 PASS regexp14.exec('b') is ['b',undefined,'b']
     43 PASS regexp15.exec('abdf') is ['abdf',undefined,'abd','f']
     44 PASS regexp16.exec('abc') is ['ab','a','b']
     45 PASS regexp17.exec('bcaDxqy') is ['Dx','D']
     46 PASS regexp18.exec('Hello: World') is ['Hello:',':']
     47 PASS regexp19.exec('barrel') is ['bar','']
     48 PASS regexp20.exec('barrel') is ['barrel','rel']
     49 PASS regexp20.exec('2barrel') is ['2barrel','rel']
     50 PASS regexp21.exec('abc') is ['ab','ab','b']
     51 PASS regexp22.exec('abcdlskfgjdslkfg') is null
     52 PASS regexp23.exec('<html xmlns="http://www.w3.org/1999/xhtml"') is ['"http://www.w3.org/1999/xhtml"']
     53 PASS regexp24.exec('123') is null
     54 PASS regexp25.exec('this is a test') is ['this','this',undefined]
     55 PASS regexp25.exec('!this is a test') is null
     56 PASS regexp26.exec('aaa') is ['aaa',undefined,undefined]
     57 PASS regexp27.exec('file:///Users/Someone/Desktop/HelloWorld/index.html') is ['file:///Users/Someone/Desktop/HelloWorld/index.html','file','//','',undefined,undefined,undefined,'',undefined,'/Users/Someone/Desktop/HelloWorld/index.html',undefined,undefined]
     58 PASS regexp28.exec('file:///Users/Someone/Desktop/HelloWorld/index.html') is ['file:','file',undefined,undefined,undefined,undefined,undefined]
     59 PASS regexp29.exec('Committer:') is null
     60 PASS regexp30.exec('Committer:') is null
     61 PASS regexp31.exec('Committer:') is null
     62 PASS regexp32.exec('Committer:') is null
     63 PASS regexp33.exec('> <head>') is ['>',undefined,undefined,'>']
     64 PASS regexp34.exec('xyz123') is null
     65 PASS regexp34.exec('btn-abc') is ['btn-abc']
     66 PASS regexp34.exec('btn- abc') is null
     67 PASS regexp34.exec('XXbtn-abc') is null
     68 PASS regexp34.exec('XX btn-abc') is ['btn-abc']
     69 PASS regexp35.exec('ax') is ['ax','ax','a','x']
     70 PASS regexp35.exec('axx') is null
     71 PASS regexp35.exec('axxx') is ['axxx','axxx','a','xxx']
     72 PASS regexp35.exec('bx') is ['bx','bx','b','x']
     73 PASS regexp35.exec('bxx') is null
     74 PASS regexp35.exec('bxxx') is ['bxxx','bxxx','b','xxx']
     75 PASS regexp36.exec('/2011') is ['/2011','/2011','/','2011']
     76 PASS regexp36.exec('/11') is ['/11','/11','/','11']
     77 PASS regexp36.exec('/123') is null
     78 PASS regexp37.exec('7/4/1776') is ['7/4/1776','7','/','4','/1776','/','1776']
     79 PASS regexp37.exec('07-04-1776') is ['07-04-1776','07','-','04','-1776','-','1776']
     80 PASS regexp38.exec('xx') is ['xx','xx','xx']
     81 PASS regexp38.exec('b') is ['b','b',undefined]
     82 PASS regexp38.exec('z') is ['z','z',undefined]
     83 PASS regexp38.exec('') is ['','',undefined]
     84 PASS regexp39.exec('') is ['',undefined,undefined]
     85 PASS regexp39.exec('8') is ['8','8',undefined]
     86 PASS regexp39.exec('zP') is ['',undefined,undefined]
     87 PASS regexp40.exec('') is ['',undefined,undefined,undefined,'']
     88 PASS regexp40.exec('8') is ['8','8','8',undefined,'']
     89 PASS regexp40.exec('zPz') is ['',undefined,undefined,undefined,'']
     90 PASS regexp40.exec('zPPz') is ['',undefined,undefined,undefined,'']
     91 PASS regexp40.exec('zPPPz') is ['',undefined,undefined,undefined,'']
     92 PASS regexp40.exec('zPPPPz') is ['',undefined,undefined,undefined,'']
     93 PASS regexp41.exec('Here is a link: http://www.acme.com/our_products/index.html. That is all we want!') is ['http://www.acme.com/our_products/index.html','http://www.acme.com/our_products/index.html','http://','l',undefined]
     94 PASS regexp42.exec('') is ['',undefined,undefined]
     95 PASS regexp42.exec('4') is ['4','4','4']
     96 PASS regexp42.exec('4321') is ['4','4','4']
     97 PASS /(?!(?=r{0}){2,})|((z)?)?/gi.test('') is true
     98 PASS regexp43.exec('SSS') is ['']
     99 PASS regexp44.exec('SSS') is ['',undefined]
    100 PASS regexp45.exec('vt') is null
    101 PASS regexp46.exec('5') is null
    102 PASS regexp46.exec('pk') is ['pk',undefined,undefined]
    103 PASS regexp46.exec('Xw555') is ['w555','w',undefined]
    104 PASS regexp46.exec('Xw55pk5') is ['w','w','']
    105 PASS regexp47.exec('/www.acme.com/this/is/a/path/file.txt') is ['/www.acme.com/this/is/a/path/file.txt','/www.acme.com/this/is/a/path/file.txt',undefined]
    106 PASS regexp48.exec('http://www.acme.com/this/is/a/path/file.txt') is ['http://www.acme.com/this/is/a/path/file.txt','http','www.acme.com',undefined,'this/is/a/path/file.txt',undefined,undefined]
    107 PASS regexp49.exec('http://www.acme.com/this/is/a/path/file.txt') is ['http://www.acme.com/this/is/a/path/file.txt',undefined,undefined,'http','www.acme.com',undefined,'this/is/a/path/file.txt',undefined,undefined]
    108 PASS regexp50.exec('((a)b{28,}c|d)x') is null
    109 PASS regexp50.exec('abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx') is ['abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx', 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbc', 'a']
    110 PASS regexp50.exec('dx') is ['dx', 'd', undefined]
    111 PASS regexp51.exec('abc') is null
    112 PASS regexp51.exec(s) is ['){-,}P{Any}',')',undefined]
    113 PASS 'Hi Bob'.match(regexp52) is ['Bob',undefined,'Bob',undefined,undefined]
    114 PASS regexp53.exec('#') is ['',undefined,'']
    115 PASS regexp54.exec('#') is ['','',undefined,undefined,'']
    116 PASS regexp55.exec('#') is ['','']
    117 PASS regexp56.exec('a') is ['','']
    118 PASS regexp57.exec('a') is ['a','a']
    119 PASS regexp58.exec('badbc') is ['a']
    120 PASS 'Y aaa X Match1 Y aaa Y Match2 Z'.match(regexp59) is ['X Match1 Y','Y Match2 Z']
    121 PASS successfullyParsed is true
    122 
    123 TEST COMPLETE
    124 
    125