unserialize.js 1.1 KB

123456789101112131415161718192021222324
  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(t('[undefined,false,null,"raz\\"ddwa\\ntrzy",/raz/g,new Date(1234567),["foo"]]'),
  14. [undefined, false, null, 'raz"ddwa\ntrzy', /raz/g, new Date(1234567), ['foo']], "Rich Array");
  15. a.deep(t('{}'), {}, "Empty object");
  16. a.deep(t('{"raz":undefined,"dwa":false,"trzy":null,"cztery":"raz\\"ddwa\\ntrzy",' +
  17. '"szesc":/raz/g,"siedem":new Date(1234567),"osiem":["foo",32],' +
  18. '"dziewiec":{"foo":"bar","dwa":343}}'),
  19. { raz: undefined, dwa: false, trzy: null, cztery: 'raz"ddwa\ntrzy', szesc: /raz/g,
  20. siedem: new Date(1234567), osiem: ['foo', 32], dziewiec: { foo: 'bar', dwa: 343 } },
  21. "Rich object");
  22. };