demo.js 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Created by Tony on 2017/3/16.
  3. */
  4. var test = require('tape');
  5. test('basic arithmetic', function (t) {
  6. t.equal(2 + 3, 5);
  7. t.equal(7 * 8 + 9, 65);
  8. t.equal(/^-?\d+$/.test("10"), true);
  9. //t.equal(isNaN(10.1), true);
  10. t.equal(Math.round(10.4999), 10);
  11. t.end();
  12. });
  13. test('', function(t){
  14. var dt = new Date();
  15. p_fillZero = function(val){
  16. var rst = val;
  17. if (val < 10) {
  18. rst = '0' + val;
  19. }
  20. return rst;
  21. };
  22. console.log(dt.getFullYear() + '-' + p_fillZero(dt.getMonth()) + '-' + p_fillZero(dt.getDate()) + 'T' +
  23. p_fillZero(dt.getHours()) + ':' + p_fillZero(dt.getMinutes()) + ':' + p_fillZero(dt.getSeconds()) + 'Z');
  24. t.pass('just pass');
  25. t.end();
  26. })
  27. test('default sorting...', function(t){
  28. var arrSimple=new Array(1,8,7,6);
  29. arrSimple.sort();
  30. console.log(arrSimple);
  31. t.pass('just pass');
  32. t.end();
  33. })