Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/js/src/tests/non262/reflect-parse/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  newTarget.js   Sprache: JAVA

 
// |reftest| skip-if(!xulRuntime.shell)
function testNewTarget() {

    // new.target is currently valid inside any non-arrow, non-generator function
    assertInFunctionExpr("new.target", newTarget());

    // even with gratuitous whitespace.
    assertInFunctionExpr(`new.
                            target`, newTarget());

    // invalid in top-level scripts
    assertError("new.target", SyntaxError);

    // valid in arrow functions inside functions
    assertInFunctionExpr("()=>new.target", arrowExpr([], newTarget()));
    assertError("(() => new.target))", SyntaxError);

    // valid in generators, too!
    assertStmt("function *foo() { new.target; }", genFunDecl("es6", ident("foo"), [],
               blockStmt([exprStmt(newTarget())])));

    // new.target is a member expression. You should be able to call, invoke, or
    // access properties of it.
    assertInFunctionExpr("new.target.foo", dotExpr(newTarget(), ident("foo")));
    assertInFunctionExpr("new.target[\"foo\"]", memExpr(newTarget(), literal("foo")));

    assertInFunctionExpr("new.target()", callExpr(newTarget(), []));
    assertInFunctionExpr("new new.target()", newExpr(newTarget(), []));

    // assignment to newTarget is an error
    assertError("new.target = 4", SyntaxError);

    // only new.target is a valid production, no shorn names or other names
    assertError("new.", SyntaxError);
    assertError("new.foo", SyntaxError);
    assertError("new.targe", SyntaxError);

    // obj.new.target is still a member expression
    assertExpr("obj.new.target", dotExpr(dotExpr(ident("obj"), ident("new")), ident("target")));
}

runtest(testNewTarget);

Messung V0.5
C=68 H=96 G=83

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.