1// Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
2//
3// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions
5// are met:
6//
7// 1. Redistributions of source code must retain the above copyright
8// notice, this list of conditions and the following disclaimer.
9//
10// 2. Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following
12// disclaimer in the documentation and/or other materials provided
13// with the distribution.
14//
15// 3. Neither the name of the copyright holder(s) nor the names of any
16// contributors may be used to endorse or promote products derived
17// from this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30// OF THE POSSIBILITY OF SUCH DAMAGE.
31
32// Simple splice tests based on webkit layout tests.
33var arr = ['a','b','c','d'];
34assertArrayEquals(['a','b','c','d'], arr);
35assertArrayEquals(['c','d'], arr.splice(2));
36assertArrayEquals(['a','b'], arr);
37assertArrayEquals(['a','b'], arr.splice(0));
38assertArrayEquals([], arr)
39
40arr = ['a','b','c','d'];
41assertEquals([], arr.splice())
42assertArrayEquals(['a','b','c','d'], arr);
43assertArrayEquals(['a','b','c','d'], arr.splice(undefined))
44assertArrayEquals([], arr);
45
46arr = ['a','b','c','d'];
47assertArrayEquals(['a','b','c','d'], arr.splice(null))
48assertArrayEquals([], arr);
49
50arr = ['a','b','c','d'];
51assertArrayEquals([], arr.splice(100))
52assertArrayEquals(['a','b','c','d'], arr);
53assertArrayEquals(['d'], arr.splice(-1))
54assertArrayEquals(['a','b','c'], arr);
55
56assertArrayEquals([], arr.splice(2, undefined))
57assertArrayEquals([], arr.splice(2, null))
58assertArrayEquals([], arr.splice(2, -1))
59assertArrayEquals([], arr.splice(2, 0))
60assertArrayEquals(['a','b','c'], arr);
61assertArrayEquals(['c'], arr.splice(2, 100))
62assertArrayEquals(['a','b'], arr);
63