mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 08:36:12 +00:00
LibJS: Add a basic implementation of String.prototype.substr()
This commit is contained in:
parent
5c911ad4b1
commit
2d9d883274
Notes:
sideshowbarker
2024-07-19 01:11:24 +09:00
Author: https://github.com/awesomekling
Commit: 2d9d883274
4 changed files with 54 additions and 1 deletions
|
@ -0,0 +1,16 @@
|
|||
test("basic functionality", () => {
|
||||
expect(String.prototype.substr).toHaveLength(2);
|
||||
|
||||
expect("hello friends".substr()).toBe("hello friends");
|
||||
expect("hello friends".substr(1)).toBe("ello friends");
|
||||
expect("hello friends".substr(0, 5)).toBe("hello");
|
||||
expect("hello friends".substr(5, 6)).toBe(" frien");
|
||||
expect("hello friends".substr("", 5)).toBe("hello");
|
||||
expect("hello friends".substr(3, 3)).toBe("lo ");
|
||||
expect("hello friends".substr(-1, 13)).toBe("s");
|
||||
expect("hello friends".substr(0, 50)).toBe("hello friends");
|
||||
expect("hello friends".substr(0, "5")).toBe("hello");
|
||||
expect("hello friends".substr("2", "2")).toBe("ll");
|
||||
expect("hello friends".substr(-7)).toBe("friends");
|
||||
expect("hello friends".substr(-3, -5)).toBe("");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue