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

Quelle  browser_prefs-02.js   Sprache: JAVA

 
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */


"use strict";

// Tests that preference helpers work properly with custom types of Float and Json.

const { PrefsHelper } = require("resource://devtools/client/shared/prefs.js");

function test() {
  const Prefs = new PrefsHelper("prefs.helper.test", {
    float: ["Float""float"],
    json: ["Json""json"],
    jsonWithSpecialChar: ["Json""jsonWithSpecialChar"],
  });

  Prefs.registerObserver();

  // JSON
  Services.prefs.setCharPref("prefs.helper.test.json"'{"a":1}');
  is(Prefs.json.a, 1, "The JSON pref value is correctly casted on get.");

  Prefs.json = { b: 2 };
  is(
    Prefs.json.a,
    undefined,
    "The JSON pref value is correctly casted on set (1)."
  );
  is(Prefs.json.b, 2, "The JSON pref value is correctly casted on set (2).");

  // JSON with special character
  Services.prefs.setStringPref(
    "prefs.helper.test.jsonWithSpecialChar",
    `{"hello":"おはよう皆!"}`
  );
  is(
    Prefs.jsonWithSpecialChar.hello,
    "おはよう皆!",
    "The JSON pref value with a special character is correctly stored."
  );

  Prefs.jsonWithSpecialChar = { bye: "さよなら!" };
  is(
    Prefs.jsonWithSpecialChar.hello,
    undefined,
    "The JSON with the special characters pref value is correctly set. (1)"
  );
  is(
    Prefs.jsonWithSpecialChar.bye,
    "さよなら!",
    "The JSON with the special characters pref value is correctly set. (2)"
  );

  // Float
  Services.prefs.setCharPref("prefs.helper.test.float""3.14");
  is(Prefs.float, 3.14, "The float pref value is correctly casted on get.");

  Prefs.float = 6.28;
  is(Prefs.float, 6.28, "The float pref value is correctly casted on set.");

  Prefs.unregisterObserver();

  Services.prefs.clearUserPref("prefs.helper.test.float");
  Services.prefs.clearUserPref("prefs.helper.test.json");
  Services.prefs.clearUserPref("prefs.helper.test.jsonWithSpecialChar");
  finish();
}

Messung V0.5
C=90 H=96 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

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