big-numbers.js 834 B

12345678910111213141516171819202122232425262728293031
  1. var test = require('tap').test
  2. var semver = require('../')
  3. test('long version is too long', function (t) {
  4. var v = '1.2.' + new Array(256).join('1')
  5. t.throws(function () {
  6. new semver.SemVer(v)
  7. })
  8. t.equal(semver.valid(v, false), null)
  9. t.equal(semver.valid(v, true), null)
  10. t.equal(semver.inc(v, 'patch'), null)
  11. t.end()
  12. })
  13. test('big number is like too long version', function (t) {
  14. var v = '1.2.' + new Array(100).join('1')
  15. t.throws(function () {
  16. new semver.SemVer(v)
  17. })
  18. t.equal(semver.valid(v, false), null)
  19. t.equal(semver.valid(v, true), null)
  20. t.equal(semver.inc(v, 'patch'), null)
  21. t.end()
  22. })
  23. test('parsing null does not throw', function (t) {
  24. t.equal(semver.parse(null), null)
  25. t.equal(semver.parse({}), null)
  26. t.equal(semver.parse(new semver.SemVer('1.2.3')).version, '1.2.3')
  27. t.end()
  28. })