// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:querystring (legacy, deprecated since Node 11)
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.

import * as querystring from "node:querystring";

try {
  console.log("escape ascii:", querystring.escape("hello world"));
  console.log("escape special:", querystring.escape("a&b=c"));
  console.log("escape utf8:", querystring.escape("café"));
  console.log("unescape ascii:", querystring.unescape("hello%20world"));
  console.log("unescape special:", querystring.unescape("a%26b%3Dc"));
} catch (e) {
  console.log("escape/unescape ERROR:", (e as Error).message);
}

try {
  const parsed = querystring.parse("a=1&b=2&a=3");
  console.log("parse a:", parsed.a);
  console.log("parse b:", parsed.b);
  console.log("parse Object.keys:", Object.keys(parsed).sort().join(","));

  console.log("stringify basic:", querystring.stringify({ a: "1", b: "2" }));
  console.log("stringify array:", querystring.stringify({ a: ["1", "2"] }));
  console.log("stringify custom sep:", querystring.stringify({ a: "1", b: "2" }, ";", ":"));
  console.log("parse custom sep:", JSON.stringify(querystring.parse("a:1;b:2", ";", ":")));
} catch (e) {
  console.log("parse/stringify ERROR:", (e as Error).message);
}

try {
  console.log("decode === parse:", querystring.decode === querystring.parse);
  console.log("encode === stringify:", querystring.encode === querystring.stringify);
  console.log("decode call:", JSON.stringify(querystring.decode("x=1")));
  console.log("encode call:", querystring.encode({ x: "1" }));
} catch (e) {
  console.log("decode/encode ERROR:", (e as Error).message);
}
