1e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// Copyright 2009 the V8 project authors. All rights reserved.
2e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// Redistribution and use in source and binary forms, with or without
3e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// modification, are permitted provided that the following conditions are
4e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// met:
5e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//
6e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//     * Redistributions of source code must retain the above copyright
7e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       notice, this list of conditions and the following disclaimer.
8e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//     * Redistributions in binary form must reproduce the above
9e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       copyright notice, this list of conditions and the following
10e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       disclaimer in the documentation and/or other materials provided
11e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       with the distribution.
12e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//     * Neither the name of Google Inc. nor the names of its
13e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       contributors may be used to endorse or promote products derived
14e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//       from this software without specific prior written permission.
15e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org//
16e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org
28e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// Test that regular expressions can be called as functions.  Calling
29e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// a regular expression as a function corresponds to calling it's exec
30e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org// method.
31e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.org
32e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.orgvar regexp = /a(b)(c)/;
33e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.orgvar subject = "xyzabcde";
34e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.orgvar expected = 'abc,b,c';
35e959c18cf7193e2f021245584a3c8f1f32f82c92kasperl@chromium.orgassertEquals(expected, String(regexp.exec(subject)));
36c54d36599f1e72bddd09d5b7a980304c7b638048ricow@chromium.orgassertThrows(function(){ regexp(subject); });
37