Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/tests/debug/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  Object-apply-02.js

  Sprache: JAVA
 

// tests calling native functions via Debugger.Object.prototype.apply/call

load(libdir + "asserts.js");

var g = newGlobal({newCompartment: true});
g.eval("function f() { debugger; }");
var dbg = new Debugger(g);

function test(usingApply) {
    dbg.onDebuggerStatement = function (frame) {
        var max = frame.arguments[0];
        var cv = usingApply ? max.apply(null, [916]) : max.call(null916);
        assertEq(cv.return16);

        cv = usingApply ? max.apply() : max.call();
        assertEq(cv.return, -1/0);

        cv = usingApply ? max.apply(null, [253819467])
                        : max.call(null253819467);
        assertEq(cv.return9);

        // second argument to apply must be an array
        assertThrowsInstanceOf(function () { max.apply(null12); }, TypeError);
    };
    g.eval("f(Math.max);");

    dbg.onDebuggerStatement = function (frame) {
        var push = frame.arguments[0];
        var arr = frame.arguments[1];
        var cv;

        cv = usingApply ? push.apply(arr, [012]) : push.call(arr, 012);
        assertEq(cv.return3);

        cv = usingApply ? push.apply(arr, [arr]) : push.call(arr, arr);
        assertEq(cv.return4);

        cv = usingApply ? push.apply(arr) : push.call(arr);
        assertEq(cv.return4);

        // You can apply Array.prototype.push to a string; it does ToObject on
        // it.  But as the length property on String objects is non-writable,
        // attempting to increase the length will throw a TypeError.
        cv = usingApply
             ? push.apply("hello", ["world"])
             : push.call("hello""world");
        assertEq("throw" in cv, true);
        var ex = cv.throw;
        assertEq(frame.evalWithBindings("ex instanceof TypeError", { ex: ex }).returntrue);
    };
    g.eval("var a = []; f(Array.prototype.push, a);");
    assertEq(g.a.length, 4);
    assertEq(g.a.slice(03).join(","), "0,1,2");
    assertEq(g.a[3], g.a);
}

test(true);
test(false);

Messung V0.5 in Prozent
C=92 H=100 G=95

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.