mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
LibJS: Add String.prototype.slice
This commit is contained in:
parent
bf727eb44c
commit
58f6f50de4
3 changed files with 65 additions and 0 deletions
22
Libraries/LibJS/Tests/String.prototype.slice.js
Normal file
22
Libraries/LibJS/Tests/String.prototype.slice.js
Normal file
|
@ -0,0 +1,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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue