ladybird/Tests/LibJS/Runtime/regexp-legacy-static-properties-initial.js
aplefull 184c6a9a6b LibJS: Return "" for empty legacy RegExp static properties
The spec says to throw a TypeError when a legacy static property like
RegExp.$1 is accessed before any regex has matched, but all major
browsers return an empty string instead. Let's match that behavior for
compatibility.
2026-05-16 16:28:09 +02:00

16 lines
566 B
JavaScript

test("legacy static properties return empty string before any match", () => {
expect(RegExp.$1).toBe("");
expect(RegExp.$2).toBe("");
expect(RegExp.$3).toBe("");
expect(RegExp.$4).toBe("");
expect(RegExp.$5).toBe("");
expect(RegExp.$6).toBe("");
expect(RegExp.$7).toBe("");
expect(RegExp.$8).toBe("");
expect(RegExp.$9).toBe("");
expect(RegExp.input).toBe("");
expect(RegExp.lastMatch).toBe("");
expect(RegExp.lastParen).toBe("");
expect(RegExp.leftContext).toBe("");
expect(RegExp.rightContext).toBe("");
});