17c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org// Copyright 2011 the V8 project authors. All rights reserved. 243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// Redistribution and use in source and binary forms, with or without 343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// modification, are permitted provided that the following conditions are 443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// met: 543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// 643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// * Redistributions of source code must retain the above copyright 743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// notice, this list of conditions and the following disclaimer. 843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// * Redistributions in binary form must reproduce the above 943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// copyright notice, this list of conditions and the following 1043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// disclaimer in the documentation and/or other materials provided 1143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// with the distribution. 1243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// * Neither the name of Google Inc. nor the names of its 1343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// contributors may be used to endorse or promote products derived 1443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// from this software without specific prior written permission. 1543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// 1643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275ec4892aef9cca42940d7d92302abf674365f6b7ager@chromium.org 287c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org// Test that using bind several time does not change the length of existing 297c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org// bound functions. 3043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen 317c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgfunction foo() { 327c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org} 3343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen 347c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgvar f1 = function (x) {}.bind(foo); 357c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgvar f2 = function () {}; 3643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen 377c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgassertEquals(1, f1.length); 3843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen 397c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org// the object we bind to can be any object 407c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgf2.bind(foo); 4143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen 427c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgassertEquals(1, f1.length); 435ec4892aef9cca42940d7d92302abf674365f6b7ager@chromium.org 447c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgvar desc = Object.getOwnPropertyDescriptor(f1, 'length'); 457c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgassertEquals(false, desc.writable); 467c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgassertEquals(false, desc.enumerable); 477c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.orgassertEquals(false, desc.configurable); 48