1
0

serialize.js 1.1 KB

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