1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

LibJS: Add String.prototype.substring

This commit is contained in:
Kesse Jones 2020-04-16 13:15:03 -03:00 committed by Andreas Kling
parent 60d1ef6af4
commit b0b204822f
3 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,19 @@
load("test-common.js");
try {
assert(String.prototype.substring.length === 2);
assert("hello friends".substring() === "hello friends");
assert("hello friends".substring(1) === "ello friends");
assert("hello friends".substring(0, 5) === "hello");
assert("hello friends".substring(13, 6) === "friends");
assert("hello friends".substring('', 5) === "hello");
assert("hello friends".substring(3, 3) === "");
assert("hello friends".substring(-1, 13) === "hello friends");
assert("hello friends".substring(0, 50) === "hello friends");
assert("hello friends".substring(0, "5") === "hello");
assert("hello friends".substring("6", "13") === "friends");
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}