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// UC16
298bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// Characters used:
308bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda
318bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertEquals("x\u03a3\u03c3x,\u03a3",
328bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org              String(/x(.)\1x/i.exec("x\u03a3\u03c3x")), "backref-UC16");
338bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertFalse(/x(...)\1/i.test("x\u03a3\u03c2\u03c3\u03c2\u03c3"),
348bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org            "\\1 ASCII, string short");
358bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertTrue(/\u03a3((?:))\1\1x/i.test("\u03c2x"), "backref-UC16-empty");
368bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertTrue(/x(?:...|(...))\1x/i.test("x\u03a3\u03c2\u03c3x"),
378bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org           "backref-UC16-uncaptured");
388bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertTrue(/x(?:...|(...))\1x/i.test("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"),
398bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org           "backref-UC16-backtrack");
408bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgvar longUC16String = "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb";
418bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgassertEquals(longUC16String + "," + longUC16String.substring(1,4),
428bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org             String(/x(...)\1\1/i.exec(longUC16String)),
438bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org             "backref-UC16-twice");
44381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org
45381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgassertFalse(/\xc1/i.test('fooA'), "quickcheck-uc16-pattern-ascii-subject");
46381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgassertFalse(/[\xe9]/.test('i'), "charclass-uc16-pattern-ascii-subject");
47381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgassertFalse(/\u5e74|\u6708/.test('t'), "alternation-uc16-pattern-ascii-subject");
48