mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibWasm: Fix spec-test gen for inline commands and special characters
`linking.wast` has an unusual pattern for invoke commands, which is now accounted-for. Also, special unicode characters are now properly serialized in JavaScript as string literals (this is only relevant for `names.wast`).
This commit is contained in:
parent
6d097a1aa9
commit
da8633b2d0
Notes:
sideshowbarker
2024-07-16 20:44:03 +09:00
Author: https://github.com/dzfrias Commit: https://github.com/LadybirdBrowser/ladybird/commit/da8633b2d0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/582
1 changed files with 11 additions and 2 deletions
|
@ -316,12 +316,19 @@ def gen_invoke(
|
|||
*,
|
||||
fail_msg: str | None = None,
|
||||
):
|
||||
if not ctx.has_unclosed:
|
||||
print(f'describe("inline (line {line}))", () => {{\nlet _test = test;\n')
|
||||
module = "module"
|
||||
if invoke.module is not None:
|
||||
module = f'namedModules["{invoke.module}"]'
|
||||
utf8 = (
|
||||
str(invoke.field.encode("utf8"))[2:-1]
|
||||
.replace("\\'", "'")
|
||||
.replace("`", "${'`'}")
|
||||
)
|
||||
print(
|
||||
f"""_test("execution of {ctx.current_module_name}: {escape(invoke.field)} (line {line})", () => {{
|
||||
let _field = {module}.getExport("{escape(invoke.field)}");
|
||||
f"""_test(`execution of {ctx.current_module_name}: {utf8} (line {line})`, () => {{
|
||||
let _field = {module}.getExport(decodeURIComponent(escape(`{utf8}`)));
|
||||
expect(_field).not.toBeUndefined();"""
|
||||
)
|
||||
if fail_msg is not None:
|
||||
|
@ -331,6 +338,8 @@ expect(_field).not.toBeUndefined();"""
|
|||
if result is not None:
|
||||
print(f"expect(_result).toBe({gen_value(result)});")
|
||||
print("});")
|
||||
if not ctx.has_unclosed:
|
||||
print("});")
|
||||
|
||||
|
||||
def gen_get(line: int, get: Get, result: WasmValue | None, ctx: Context):
|
||||
|
|
Loading…
Reference in a new issue