unserialize.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var fn = function (raz, dwa) { return raz + dwa; };
  4. a(t("undefined"), undefined, "Undefined");
  5. a(t("null"), null, "Null");
  6. a(t("\"raz\""), "raz", "String");
  7. a(t("\"raz\\\"ddwa\\ntrzy\""), "raz\"ddwa\ntrzy", "String with escape");
  8. a(t("false"), false, "Booelean");
  9. a(String(t(String(fn))), String(fn), "Function");
  10. a.deep(t("/raz-dwa/g"), /raz-dwa/g, "RegExp");
  11. a.deep(t("new Date(1234567)"), new Date(1234567), "Date");
  12. a.deep(t("[]"), [], "Empty array");
  13. a.deep(
  14. t("[undefined,false,null,\"raz\\\"ddwa\\ntrzy\",/raz/g,new Date(1234567),[\"foo\"]]"),
  15. [undefined, false, null, "raz\"ddwa\ntrzy", /raz/g, new Date(1234567), ["foo"]],
  16. "Rich Array"
  17. );
  18. a.deep(t("{}"), {}, "Empty object");
  19. a.deep(
  20. t(
  21. "{\"raz\":undefined,\"dwa\":false,\"trzy\":null,\"cztery\":\"raz\\\"ddwa\\ntrzy\"," +
  22. "\"szesc\":/raz/g,\"siedem\":new Date(1234567),\"osiem\":[\"foo\",32]," +
  23. "\"dziewiec\":{\"foo\":\"bar\",\"dwa\":343}}"
  24. ),
  25. {
  26. raz: undefined,
  27. dwa: false,
  28. trzy: null,
  29. cztery: "raz\"ddwa\ntrzy",
  30. szesc: /raz/g,
  31. siedem: new Date(1234567),
  32. osiem: ["foo", 32],
  33. dziewiec: { foo: "bar", dwa: 343 }
  34. },
  35. "Rich object"
  36. );
  37. };