quickjs/tests/function_source.js
Ben Noordhuis 5cbf8727a6
Retain function source code in serialized bytecode (#218)
Also fix a small memory leak in the output from `qjsc -e`.

Fixes: https://github.com/quickjs-ng/quickjs/issues/217
2023-12-16 01:01:26 +01:00

14 lines
285 B
JavaScript

"use strict"
const expect = "function f() { return 42 }"
function f() { return 42 }
{
const actual = f.toString()
if (actual !== expect) throw Error(actual)
}
{
const f = eval(expect + "f")
const actual = f.toString()
if (actual !== expect) throw Error(actual)
}