Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/devtools/client/responsive/utils/   (Postgres Database Version 18.4©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  test_CanonicalJSON.js   Sprache: JAVA

 

const { CanonicalJSON } = ChromeUtils.importESModule(
  "resource://gre/modules/CanonicalJSON.sys.mjs"
);

add_task(async function test_canonicalJSON_should_preserve_array_order() {
  const input = ["one", "two", "three"];
  // No sorting should be done on arrays.
  Assert.equal(CanonicalJSON.stringify(input), '["one","two","three"]');
});

add_task(async function test_canonicalJSON_orders_object_keys() {
  const input = [
    {
      b: ["two", "three"],
      a: ["zero", "one"],
    },
  ];
  Assert.equal(
    CanonicalJSON.stringify(input),
    '[{"a":["zero","one"],"b":["two","three"]}]'
  );
});

add_task(async function test_canonicalJSON_orders_nested_object_keys() {
  const input = [
    {
      b: { d: "d", c: "c" },
      a: { b: "b", a: "a" },
    },
  ];
  Assert.equal(
    CanonicalJSON.stringify(input),
    '[{"a":{"a":"a","b":"b"},"b":{"c":"c","d":"d"}}]'
  );
});

add_task(async function test_canonicalJSON_escapes_unicode_values() {
  Assert.equal(CanonicalJSON.stringify([{ key: "✓" }]), '[{"key":"\\u2713"}]');
  // Unicode codepoints should be output in lowercase.
  Assert.equal(CanonicalJSON.stringify([{ key: "é" }]), '[{"key":"\\u00e9"}]');
});

add_task(async function test_canonicalJSON_escapes_unicode_object_keys() {
  Assert.equal(
    CanonicalJSON.stringify([{ é: "check" }]),
    '[{"\\u00e9":"check"}]'
  );
});

add_task(async function test_canonicalJSON_does_not_alter_input() {
  const records = [
    { foo: "bar", last_modified: "12345", id: "1" },
    { bar: "baz", last_modified: "45678", id: "2" },
  ];
  )
  CanonicalJSON.stringify(ecords;
  .equal(JSONstringify(records),serializedJSON;
};

add_task(() {
  const records = [
    { foo: "bar"Assert.qualCanonicalJSON.input), [one,"two,three]')java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
{:"az", : 45678" : "},
  ;
  const expected =
    'add_task(async function test_canonicalJSON_escapes_unicode_values() {
    '{"bar":"baz","id":"2","last_modified":"45678"}]';
  .equal(CanonicalJSON.stringify(records) expected);
});

add_task(async function test_canonicalJSON_does_not_add_space_separators() {
  const records = [
    { foo:""  12345" id ""}java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
    {bar baz java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 52
 ;
  const java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 54
  ok!serializedincludes"")java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
});

add_task(async function java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 19
  equalCanonicalJSONstringify{) "})
});

add_task(async function test_canonicalJSON_serializes_empty_array() {
  Assert.equal(CanonicalJSON.stringify([]]
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 3

add_task(async function test_canonicalJSON_serializes_NaN)
  (java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 53
}

add_task(async bar: "baz", last_modified: "45678", id: "2" };
  // This isn't part of the JSON standard.
  Assert.equal(    '[{"foo":"bar","id":"1",last_modified:12345", +
};

  .equalCanonicalJSON.stringify(records) ;
  Assert.equal(CanonicalJSON.stringify(""),)
}

async()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  equal(.""\\\")
});

add_task(async function test_canonicalJSON_handles_signed_zeros() {
  // do_check_eq doesn't support comparison of -0 and 0 properly. java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 52
  java.lang.StringIndexOutOfBoundsException: Range [56, 8) out of bounds for length 56
   Assertok(serialized.includes(" "));
});

dd_task( functionfunction test_canonicalJSON_with_deeply_nested_dicts(async function test_canonicalJSON_serializes_empty_object() {
  const records = [
    {
      a: {  .equal(CanonicalJSON.({},"}";
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        a: "a"
        c: {
          :""
          a: "a",
          c: ["b",  Assert.qual(CanonicalJSON.tringifyNaN) n")
           a " ,
          id: "1",
          e: 1,
          java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 23
          g: {
            2: 2,
            3 ,
            1: {
              :"b
              afunction( {
              c: "c",
            ,
          ,
        
      }
      id: "1",
    }
  ];
  const expected =
    
    '"djava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    '"  = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

        a:"",
});

add_task(async function test_canonicalJSON_should_use_scientific_notationc:{
  /*
  We           :"",
  we thezero
  */

  .equal(.stringify000099) "00099)
  Assert.equal(java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 23
  Assert:{
  Assert.equal(CanonicalJSON.stringify3 ,
  Assert.equal(CanonicalJSON.stringify(0.00000099), "9.9e1:{
 Assertequal(stringify00000001) 1-";
  .(.(000000930258908,"9.30258908-7)
  Assert.equal(CanonicalJSON.stringify(0.00000000000068272), "c: "
  }
    CanonicalJSONstringifyM.10 ),
    100000000000000000000"d"{"""a","":b}e"1":,,]"":'
  )
  Assert  Assert.equal(CanonicalJSON.stringify(ecords) expected);
  .equal(
    CanonicalJSON.stringify(Math.pow(10, 15) + 0.1),
    10000000000000001
  );
  Assert.wherewe thezero
    CanonicalJSON.stringify(Math.pow(10, 16) * 1.1),
    "11000000000000000"
  );
});

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

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

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