Implement function.toString operation (#4752)

May increase the memory consumtpion heavily.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-08-31 13:37:25 +02:00
committed by GitHub
parent 1c6b18ecdf
commit 6649940ea6
37 changed files with 1002 additions and 192 deletions
+16 -5
View File
@@ -12,16 +12,27 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert (Math.cos.toString() === "function(){/* ecmascript */}");
assert (Math.cos.toString() === "function () { [native code] }");
var has_toString = none.toString() != "function () { /* ecmascript */ }"
function check(f, expected)
{
assert (f.toString() === (has_toString ? expected : "function () { /* ecmascript */ }"))
}
function none() { return 1; }
assert (none.toString() === "function(){/* ecmascript */}");
check (none, "function none() { return 1; }")
assert (none.bind({}).toString() === "function () { [native code] }")
function single(b) { return 1; }
assert (single.toString() === "function(){/* ecmascript */}");
check (single, "function single(b) { return 1; }")
assert (single.bind({}).toString() === "function () { [native code] }")
function multiple(a,b) { return 1; }
assert (multiple.toString() === "function(){/* ecmascript */}");
check (multiple, "function multiple(a,b) { return 1; }")
assert (multiple.bind({}).toString() === "function () { [native code] }")
function lots(a,b,c,d,e,f,g,h,i,j,k) { return 1; }
assert (lots.toString() === "function(){/* ecmascript */}");
check (lots, "function lots(a,b,c,d,e,f,g,h,i,j,k) { return 1; }")
assert (lots.bind({}).toString() === "function () { [native code] }")