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

Quelle  object-rest.js

  Sprache: JAVA
 

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

function property(key, value = key, shorthand = key === value) {
    return { key, value, shorthand };
}

function assertDestrAssign(src, pattern) {
    assertExpr(`(${src} = 0)`, aExpr("=", pattern, lit(0)));
}

function assertDestrBinding(src, pattern) {
    assertDecl(`var ${src} = 0`, varDecl([{id: pattern, init: lit(0)}]));
}

function test() {
    // Target expression must be a simple assignment target in object assignment patterns.
    assertDestrAssign("{...x}", objPatt([spread(ident("x"))]));
    assertDestrAssign("{...(x)}", objPatt([spread(ident("x"))]));
    assertDestrAssign("{...obj.p}", objPatt([spread(dotExpr(ident("obj"), ident("p")))]));
    assertDestrAssign("{...(obj.p)}", objPatt([spread(dotExpr(ident("obj"), ident("p")))]));

    // Object binding patterns only allow binding identifiers.
    assertDestrBinding("{...x}", objPatt([spread(ident("x"))]));

    // The rest-property can be preceded by other properties.
    for (var assertDestr of [assertDestrAssign, assertDestrBinding]) {
        assertDestr("{a, ...x}", objPatt([property(ident("a")), spread(ident("x"))]));
        assertDestr("{a: b, ...x}", objPatt([property(ident("a"), ident("b")), spread(ident("x"))]));
        assertDestr("{[a]: b, ...x}", objPatt([property(comp(ident("a")), ident("b")), spread(ident("x"))]));
    }

    // Tests when __proto__ is used in the object pattern.
    for (var assertDestr of [assertDestrAssign, assertDestrBinding]) {
        assertDestr("{...__proto__}", objPatt([spread(ident("__proto__"))]));
        assertDestr("{__proto__, ...x}", objPatt([property(ident("__proto__")), spread(ident("x"))]));
    }
    assertDestrAssign("{__proto__: a, ...x}", objPatt([property(lit("__proto__"), ident("a")), spread(ident("x"))]));
    assertDestrBinding("{__proto__: a, ...x}", objPatt([property(ident("__proto__"), ident("a")), spread(ident("x"))]));
}

runtest(test);

Messung V0.5 in Prozent
C=90 H=94 G=91

¤ Dauer der Verarbeitung: 0.8 Sekunden  (vorverarbeitet am  2026-06-08) ¤

*© 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.