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:
parent
60d1ef6af4
commit
b0b204822f
3 changed files with 68 additions and 0 deletions
19
Libraries/LibJS/Tests/String.prototype.substring.js
Normal file
19
Libraries/LibJS/Tests/String.prototype.substring.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue