forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
String.prototype.slice.js
22 lines (20 loc) 路 866 Bytes
/
String.prototype.slice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
load("test-common.js");
try {
assert(String.prototype.slice.length === 2);
assert("hello friends".slice() === "hello friends");
assert("hello friends".slice(1) === "ello friends");
assert("hello friends".slice(0, 5) === "hello");
assert("hello friends".slice(13, 6) === "");
assert("hello friends".slice('', 5) === "hello");
assert("hello friends".slice(3, 3) === "");
assert("hello friends".slice(-1, 13) === "s");
assert("hello friends".slice(0, 50) === "hello friends");
assert("hello friends".slice(0, "5") === "hello");
assert("hello friends".slice("6", "13") === "friends");
assert("hello friends".slice(-7) === "friends");
assert("hello friends".slice(1000) === "");
assert("hello friends".slice(-1000) === "hello friends");
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}