149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Copyright 2011 the V8 project authors. All rights reserved.
249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Redistribution and use in source and binary forms, with or without
349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// modification, are permitted provided that the following conditions are
449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// met:
549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//
649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Redistributions of source code must retain the above copyright
749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       notice, this list of conditions and the following disclaimer.
849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Redistributions in binary form must reproduce the above
949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       copyright notice, this list of conditions and the following
1049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       disclaimer in the documentation and/or other materials provided
1149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       with the distribution.
1249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Neither the name of Google Inc. nor the names of its
1349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       contributors may be used to endorse or promote products derived
1449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       from this software without specific prior written permission.
1549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//
1649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
2849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Test that the Number, String and Boolean prototypes are searched
2949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// for indexed properties on value objects.
3049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
3149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgfunction return_one() { return 1; };
3249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
3349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgfunction test(value) {
3449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org  for (var i = 0; i < 10; i++) {
3549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(0, (value)[0]);
3649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(0, (value)["0"]);
3749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(return_one, (value)[1]);
3849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(return_one, (value)["1"]);
3949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(1, (value)[1]());
4049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org    assertEquals(1, (value)["1"]());
4149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org  }
4249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org}
4349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
4449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgNumber.prototype[0] = 0;
4549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgNumber.prototype[1] = return_one;
4649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgtest(0);
4749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgtest(0.1);
4849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
4949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgString.prototype[0] = 0;
5049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgString.prototype[1] = return_one;
5149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgtest("");
5249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
5349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgBoolean.prototype[0] = 0;
5449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgBoolean.prototype[1] = return_one;
5549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgtest(true);
5649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgtest(false);
57