Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

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 in Prozent
C=89 H=96 G=92

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-08-27) ¤

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=476070
#Domains=661743