Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/base/test/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  test_chromeutils_defineLazyGetter.js   Sprache: JAVA

 
"use strict";

add_task(function test_defineLazyGetter() {
  let accessCount = 0;
  let obj = {
    inScope: false,
  };
  const TEST_VALUE = "test value";
  ChromeUtils.defineLazyGetter(obj, "foo"function () {
    accessCount++;
    this.inScope = true;
    return TEST_VALUE;
  });
  Assert.equal(accessCount, 0);

  // Get the property, making sure the access count has increased.
  Assert.equal(obj.foo, TEST_VALUE);
  Assert.equal(accessCount, 1);
  Assert.ok(obj.inScope);

  // Get the property once more, making sure the access count has not
  // increased.
  Assert.equal(obj.foo, TEST_VALUE);
  Assert.equal(accessCount, 1);
});

add_task(function test_defineLazyGetter_name() {
  // Properties that are convertible to NonIntAtom should be reflected to
  // the getter name.
  for (const name of [
    "foo",
    "\u3042",
    true,
    false,
    -1,
    1.1,
    0.1,
    null,
    undefined,
    {},
    [],
    /a/,
  ]) {
    const obj = {};
    const v = {};
    ChromeUtils.defineLazyGetter(obj, name, () => v);
    Assert.equal(
      Object.getOwnPropertyDescriptor(obj, name).get.name,
      String(name)
    );
    Assert.equal(obj[name], v);
    Assert.equal(obj[name], v);
  }

  // Int and Symbol properties are not reflected to the getter name.
  for (const name of [
    0,
    10,
    Symbol.iterator,
    Symbol("foo"),
    Symbol.for("foo"),
  ]) {
    const obj = {};
    const v = {};
    ChromeUtils.defineLazyGetter(obj, name, () => v);
    Assert.equal(Object.getOwnPropertyDescriptor(obj, name).get.name, "");
    Assert.equal(obj[name], v);
    Assert.equal(obj[name], v);
  }
});

Messung V0.5
C=92 H=82 G=86

¤ Dauer der Verarbeitung: 0.1 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.