1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15var str = "universe"; 16var res; 17 18res = str.slice(); 19assert (res === "universe"); 20 21res = str.slice(1, 6); 22assert (res === "niver"); 23 24res = str.slice("a", "-4"); 25assert (res === "univ"); 26 27res = str.slice(-5); 28assert (res === "verse"); 29 30res = str.slice(-12, undefined); 31assert (res === "universe"); 32 33res = str.slice(undefined, -20); 34assert (res === ""); 35 36res = str.slice(undefined, undefined); 37assert (res === "universe"); 38 39res = str.slice(Infinity, NaN); 40assert (res === ""); 41 42res = str.slice(-Infinity, Infinity); 43assert (res === "universe"); 44 45res = str.slice(NaN, -Infinity); 46assert (res === ""); 47 48res = str.slice(false, true); 49assert (res === "u"); 50 51var x; 52res = str.slice(x, x); 53assert (res === "universe"); 54 55var obj = {y: "foo"}; 56var arr = [x, x]; 57res = str.slice(obj, arr); 58assert (res === ""); 59