14f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// Copyright 2011 the V8 project authors. All rights reserved.
24f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// Redistribution and use in source and binary forms, with or without
34f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// modification, are permitted provided that the following conditions are
44f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// met:
54f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//
64f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//     * Redistributions of source code must retain the above copyright
74f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       notice, this list of conditions and the following disclaimer.
84f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//     * Redistributions in binary form must reproduce the above
94f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       copyright notice, this list of conditions and the following
104f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       disclaimer in the documentation and/or other materials provided
114f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       with the distribution.
124f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//     * Neither the name of Google Inc. nor the names of its
134f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       contributors may be used to endorse or promote products derived
144f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//       from this software without specific prior written permission.
154f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org//
164f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org
284f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// Check the receiver for the sort and replace functions to
294f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org// Array.prototype.sort and String.prototype.replace.
304f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org
314f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.orgvar global = this;
324f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.orgfunction strict() { "use strict"; assertEquals(void 0, this); }
334f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.orgfunction non_strict() { assertEquals(global, this); }
344f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org
354f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org[1,2,3].sort(strict);
364f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org[1,2,3].sort(non_strict);
374f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org
384f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org"axc".replace("x", strict);
394f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org"axc".replace("x", non_strict);
40