unserialize.js 1.2 KB

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