18bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// Copyright 2008 the V8 project authors. All rights reserved.
28bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// Redistribution and use in source and binary forms, with or without
38bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// modification, are permitted provided that the following conditions are
48bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// met:
58bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//
68bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//     * Redistributions of source code must retain the above copyright
78bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       notice, this list of conditions and the following disclaimer.
88bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//     * Redistributions in binary form must reproduce the above
98bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       copyright notice, this list of conditions and the following
108bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       disclaimer in the documentation and/or other materials provided
118bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       with the distribution.
128bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//     * Neither the name of Google Inc. nor the names of its
138bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       contributors may be used to endorse or promote products derived
148bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//       from this software without specific prior written permission.
158bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org//
168bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
188bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
248bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org
288bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// See http://code.google.com/p/v8/issues/detail?id=176
298bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org
30160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["f", undefined],
31160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o))?f/),
32160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "zero length match in (?:) with capture in lookahead");
33160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["f", undefined],
34160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?=(f)o)?f/),
35160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "zero length match in (?=) with capture in lookahead");
36160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["fo", "f"],
37160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o)f)?o/),
38160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "non-zero length match with capture in lookahead");
39160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["fo", "f"],
40160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o)f?)?o/),
41160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "non-zero length match with greedy ? in (?:)");
42160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["fo", "f"],
43160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o)f??)?o/),
44160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "non-zero length match with non-greedy ? in (?:), o forces backtrack");
45160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["fo", "f"],
46160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o)f??)?./),
47160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "non-zero length match with non-greedy ? in (?:), zero length match causes backtrack");
48160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertArrayEquals(["f", undefined],
49160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "foo".match(/(?:(?=(f)o)fx)?./),
50160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.org                  "x causes backtrack inside (?:)");
51