mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
48
Libraries/LibJS/Tests/iterators/string-iterator.js
Normal file
48
Libraries/LibJS/Tests/iterators/string-iterator.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
test("length", () => {
|
||||
expect(String.prototype[Symbol.iterator]).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const s = "abcd";
|
||||
const it = s[Symbol.iterator]();
|
||||
expect(it.next()).toEqual({ value: "a", done: false });
|
||||
expect(it.next()).toEqual({ value: "b", done: false });
|
||||
expect(it.next()).toEqual({ value: "c", done: false });
|
||||
expect(it.next()).toEqual({ value: "d", done: false });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
});
|
||||
|
||||
test("casts |this| to string", () => {
|
||||
let it = String.prototype[Symbol.iterator].call(45);
|
||||
expect(it.next()).toEqual({ value: "4", done: false });
|
||||
expect(it.next()).toEqual({ value: "5", done: false });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
|
||||
it = String.prototype[Symbol.iterator].call(false);
|
||||
expect(it.next()).toEqual({ value: "f", done: false });
|
||||
expect(it.next()).toEqual({ value: "a", done: false });
|
||||
expect(it.next()).toEqual({ value: "l", done: false });
|
||||
expect(it.next()).toEqual({ value: "s", done: false });
|
||||
expect(it.next()).toEqual({ value: "e", done: false });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
|
||||
expect(() => {
|
||||
String.prototype[Symbol.iterator].call(null);
|
||||
}).toThrowWithMessage(TypeError, "null cannot be converted to an object");
|
||||
expect(() => {
|
||||
String.prototype[Symbol.iterator].call(undefined);
|
||||
}).toThrowWithMessage(TypeError, "undefined cannot be converted to an object");
|
||||
});
|
||||
|
||||
test("utf8 compatible", () => {
|
||||
const it = "ab\u{1f41e}cde"[Symbol.iterator]();
|
||||
expect(it.next()).toEqual({ value: "a", done: false });
|
||||
expect(it.next()).toEqual({ value: "b", done: false });
|
||||
expect(it.next()).toEqual({ value: "🐞", done: false });
|
||||
expect(it.next()).toEqual({ value: "c", done: false });
|
||||
expect(it.next()).toEqual({ value: "d", done: false });
|
||||
expect(it.next()).toEqual({ value: "e", done: false });
|
||||
expect(it.next()).toEqual({ value: undefined, done: true });
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue