1 var tap = require('tap');
3 var semver = require('../semver.js');
11 var satisfies = semver.satisfies;
12 var validRange = semver.validRange;
14 var replaceStars = semver.replaceStars;
15 var toComparators = semver.toComparators;
16 var SemVer = semver.SemVer;
17 var Range = semver.Range;
19 test('\ncomparison tests', function(t) {
20 // [version1, version2]
21 // version1 should be greater than version2
22 [['0.0.0', '0.0.0-foo'],
28 ['v0.0.0', '0.0.0-foo', true],
29 ['v0.0.1', '0.0.0', true],
30 ['v1.0.0', '0.9.9', true],
31 ['v0.10.0', '0.9.0', true],
32 ['v0.99.0', '0.10.0', true],
33 ['v2.0.0', '1.2.3', true],
34 ['0.0.0', 'v0.0.0-foo', true],
35 ['0.0.1', 'v0.0.0', true],
36 ['1.0.0', 'v0.9.9', true],
37 ['0.10.0', 'v0.9.0', true],
38 ['0.99.0', 'v0.10.0', true],
39 ['2.0.0', 'v1.2.3', true],
40 ['1.2.3', '1.2.3-asdf'],
42 ['1.2.3', '1.2.3-4-foo'],
43 ['1.2.3-5-foo', '1.2.3-5'],
44 ['1.2.3-5', '1.2.3-4'],
45 ['1.2.3-5-foo', '1.2.3-5-Foo'],
46 ['3.0.0', '2.7.2+asdf'],
47 ['1.2.3-a.10', '1.2.3-a.5'],
48 ['1.2.3-a.b', '1.2.3-a.5'],
49 ['1.2.3-a.b', '1.2.3-a'],
50 ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100']
51 ].forEach(function(v) {
55 t.ok(gt(v0, v1, loose), "gt('" + v0 + "', '" + v1 + "')");
56 t.ok(lt(v1, v0, loose), "lt('" + v1 + "', '" + v0 + "')");
57 t.ok(!gt(v1, v0, loose), "!gt('" + v1 + "', '" + v0 + "')");
58 t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
59 t.ok(eq(v0, v0, loose), "eq('" + v0 + "', '" + v0 + "')");
60 t.ok(eq(v1, v1, loose), "eq('" + v1 + "', '" + v1 + "')");
61 t.ok(neq(v0, v1, loose), "neq('" + v0 + "', '" + v1 + "')");
62 t.ok(cmp(v1, '==', v1, loose), "cmp('" + v1 + "' == '" + v1 + "')");
63 t.ok(cmp(v0, '>=', v1, loose), "cmp('" + v0 + "' >= '" + v1 + "')");
64 t.ok(cmp(v1, '<=', v0, loose), "cmp('" + v1 + "' <= '" + v0 + "')");
65 t.ok(cmp(v0, '!=', v1, loose), "cmp('" + v0 + "' != '" + v1 + "')");
70 test('\nequality tests', function(t) {
71 // [version1, version2]
72 // version1 should be equivalent to version2
73 [['1.2.3', 'v1.2.3', true],
74 ['1.2.3', '=1.2.3', true],
75 ['1.2.3', 'v 1.2.3', true],
76 ['1.2.3', '= 1.2.3', true],
77 ['1.2.3', ' v1.2.3', true],
78 ['1.2.3', ' =1.2.3', true],
79 ['1.2.3', ' v 1.2.3', true],
80 ['1.2.3', ' = 1.2.3', true],
81 ['1.2.3-0', 'v1.2.3-0', true],
82 ['1.2.3-0', '=1.2.3-0', true],
83 ['1.2.3-0', 'v 1.2.3-0', true],
84 ['1.2.3-0', '= 1.2.3-0', true],
85 ['1.2.3-0', ' v1.2.3-0', true],
86 ['1.2.3-0', ' =1.2.3-0', true],
87 ['1.2.3-0', ' v 1.2.3-0', true],
88 ['1.2.3-0', ' = 1.2.3-0', true],
89 ['1.2.3-1', 'v1.2.3-1', true],
90 ['1.2.3-1', '=1.2.3-1', true],
91 ['1.2.3-1', 'v 1.2.3-1', true],
92 ['1.2.3-1', '= 1.2.3-1', true],
93 ['1.2.3-1', ' v1.2.3-1', true],
94 ['1.2.3-1', ' =1.2.3-1', true],
95 ['1.2.3-1', ' v 1.2.3-1', true],
96 ['1.2.3-1', ' = 1.2.3-1', true],
97 ['1.2.3-beta', 'v1.2.3-beta', true],
98 ['1.2.3-beta', '=1.2.3-beta', true],
99 ['1.2.3-beta', 'v 1.2.3-beta', true],
100 ['1.2.3-beta', '= 1.2.3-beta', true],
101 ['1.2.3-beta', ' v1.2.3-beta', true],
102 ['1.2.3-beta', ' =1.2.3-beta', true],
103 ['1.2.3-beta', ' v 1.2.3-beta', true],
104 ['1.2.3-beta', ' = 1.2.3-beta', true],
105 ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true],
106 ['1.2.3+build', ' = 1.2.3+otherbuild', true],
107 ['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
108 ['1.2.3+build', '1.2.3+otherbuild'],
109 [' v1.2.3+build', '1.2.3+otherbuild']
110 ].forEach(function(v) {
114 t.ok(eq(v0, v1, loose), "eq('" + v0 + "', '" + v1 + "')");
115 t.ok(!neq(v0, v1, loose), "!neq('" + v0 + "', '" + v1 + "')");
116 t.ok(cmp(v0, '==', v1, loose), 'cmp(' + v0 + '==' + v1 + ')');
117 t.ok(!cmp(v0, '!=', v1, loose), '!cmp(' + v0 + '!=' + v1 + ')');
118 t.ok(!cmp(v0, '===', v1, loose), '!cmp(' + v0 + '===' + v1 + ')');
119 t.ok(cmp(v0, '!==', v1, loose), 'cmp(' + v0 + '!==' + v1 + ')');
120 t.ok(!gt(v0, v1, loose), "!gt('" + v0 + "', '" + v1 + "')");
121 t.ok(gte(v0, v1, loose), "gte('" + v0 + "', '" + v1 + "')");
122 t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
123 t.ok(lte(v0, v1, loose), "lte('" + v0 + "', '" + v1 + "')");
129 test('\nrange tests', function(t) {
131 // version should be included by range
132 [['1.0.0 - 2.0.0', '1.2.3'],
137 ['*', 'v1.2.3-foo', true],
138 ['>=1.0.0', '1.0.0'],
139 ['>=1.0.0', '1.0.1'],
140 ['>=1.0.0', '1.1.0'],
143 ['<=2.0.0', '2.0.0'],
144 ['<=2.0.0', '1.9999.9999'],
145 ['<=2.0.0', '0.2.9'],
146 ['<2.0.0', '1.9999.9999'],
148 ['>= 1.0.0', '1.0.0'],
149 ['>= 1.0.0', '1.0.1'],
150 ['>= 1.0.0', '1.1.0'],
151 ['> 1.0.0', '1.0.1'],
152 ['> 1.0.0', '1.1.0'],
153 ['<= 2.0.0', '2.0.0'],
154 ['<= 2.0.0', '1.9999.9999'],
155 ['<= 2.0.0', '0.2.9'],
156 ['< 2.0.0', '1.9999.9999'],
157 ['<\t2.0.0', '0.2.9'],
158 ['>=0.1.97', 'v0.1.97', true],
159 ['>=0.1.97', '0.1.97'],
160 ['0.1.20 || 1.2.4', '1.2.4'],
161 ['>=0.2.3 || <0.0.1', '0.0.0'],
162 ['>=0.2.3 || <0.0.1', '0.2.3'],
163 ['>=0.2.3 || <0.0.1', '0.2.4'],
167 ['1.2.x || 2.x', '2.1.3'],
168 ['1.2.x || 2.x', '1.2.3'],
172 ['1.2.* || 2.*', '2.1.3'],
173 ['1.2.* || 2.*', '1.2.3'],
177 ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
179 ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0,
180 ['~1', '1.2.3'], // >=1.0.0 <2.0.0
183 ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0,
185 ['~ 1.0.3', '1.0.12'],
190 ['1', '1.0.0beta', true],
191 ['~v0.5.4-pre', '0.5.5'],
192 ['~v0.5.4-pre', '0.5.4'],
194 ['>=0.7.x', '0.7.2'],
195 ['=0.7.x', '0.7.0-asdf'],
196 ['>=0.7.x', '0.7.0-asdf'],
197 ['<=0.7.x', '0.6.2'],
198 ['~1.2.1 >=1.2.3', '1.2.3'],
199 ['~1.2.1 =1.2.3', '1.2.3'],
200 ['~1.2.1 1.2.3', '1.2.3'],
201 ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'],
202 ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'],
203 ['~1.2.1 1.2.3', '1.2.3'],
204 ['>=1.2.1 1.2.3', '1.2.3'],
205 ['1.2.3 >=1.2.1', '1.2.3'],
206 ['>=1.2.3 >=1.2.1', '1.2.3'],
207 ['>=1.2.1 >=1.2.3', '1.2.3'],
208 ['<=1.2.3', '1.2.3-beta'],
209 ['>1.2', '1.3.0-beta'],
212 ['^1.2.3', '1.2.3-beta'],
216 ['^1.2 ^1', '1.4.2'],
217 ['^1.2', '1.2.0-pre'],
218 ['^1.2.3', '1.2.3-pre']
219 ].forEach(function(v) {
223 t.ok(satisfies(ver, range, loose), range + ' satisfied by ' + ver);
228 test('\nnegative range tests', function(t) {
230 // version should not be included by range
231 [['1.0.0 - 2.0.0', '2.2.3'],
233 ['>=1.0.0', '0.0.0'],
234 ['>=1.0.0', '0.0.1'],
235 ['>=1.0.0', '0.1.0'],
238 ['<=2.0.0', '3.0.0'],
239 ['<=2.0.0', '2.9999.9999'],
240 ['<=2.0.0', '2.2.9'],
241 ['<2.0.0', '2.9999.9999'],
243 ['>=0.1.97', 'v0.1.93', true],
244 ['>=0.1.97', '0.1.93'],
245 ['0.1.20 || 1.2.4', '1.2.3'],
246 ['>=0.2.3 || <0.0.1', '0.0.3'],
247 ['>=0.2.3 || <0.0.1', '0.2.2'],
251 ['1.2.x || 2.x', '3.1.3'],
252 ['1.2.x || 2.x', '1.1.3'],
256 ['1.2.* || 2.*', '3.1.3'],
257 ['1.2.* || 2.*', '1.1.3'],
260 ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
262 ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
263 ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
264 ['~1', '0.2.3'], // >=1.0.0 <2.0.0
266 ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
269 ['1', '2.0.0beta', true],
270 ['~v0.5.4-beta', '0.5.4-alpha'],
271 ['<1', '1.0.0beta', true],
272 ['< 1', '1.0.0beta', true],
274 ['>=0.7.x', '0.6.2'],
275 ['<=0.7.x', '0.7.2'],
276 ['<1.2.3', '1.2.3-beta'],
277 ['=1.2.3', '1.2.3-beta'],
279 ['^1.2.3', '2.0.0-alpha'],
282 // invalid ranges never satisfied!
284 ['git+https://user:password0123@github.com/foo', '123.0.0', true],
285 ['^1.2.3', '2.0.0-pre']
286 ].forEach(function(v) {
290 var found = satisfies(ver, range, loose);
291 t.ok(!found, ver + ' not satisfied by ' + range);
296 test('\nincrement versions test', function(t) {
297 // [version, inc, result]
298 // inc(version, inc) -> result
299 [['1.2.3', 'major', '2.0.0'],
300 ['1.2.3', 'minor', '1.3.0'],
301 ['1.2.3', 'patch', '1.2.4'],
302 ['1.2.3tag', 'major', '2.0.0', true],
303 ['1.2.3-tag', 'major', '2.0.0'],
304 ['1.2.3', 'fake', null],
305 ['fake', 'major', null],
306 ['1.2.3', 'prerelease', '1.2.3-0'],
307 ['1.2.3-0', 'prerelease', '1.2.3-1'],
308 ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'],
309 ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'],
310 ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'],
311 ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'],
312 ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'],
313 ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'],
314 ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'],
315 ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'],
316 ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'],
317 ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'],
318 ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'],
319 ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'],
320 ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'],
321 ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'],
322 ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta']
323 ].forEach(function(v) {
328 var found = inc(pre, what, loose);
329 t.equal(found, wanted, 'inc(' + pre + ', ' + what + ') === ' + wanted);
335 test('\nvalid range test', function(t) {
337 // validRange(range) -> result
338 // translate ranges into their canonical form
339 [['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'],
341 ['>=*', '>=0.0.0-0'],
345 ['>=1.0.0', '>=1.0.0'],
346 ['>1.0.0', '>1.0.0'],
347 ['<=2.0.0', '<=2.0.0'],
348 ['1', '>=1.0.0-0 <2.0.0-0'],
349 ['<=2.0.0', '<=2.0.0'],
350 ['<=2.0.0', '<=2.0.0'],
351 ['<2.0.0', '<2.0.0-0'],
352 ['<2.0.0', '<2.0.0-0'],
353 ['>= 1.0.0', '>=1.0.0'],
354 ['>= 1.0.0', '>=1.0.0'],
355 ['>= 1.0.0', '>=1.0.0'],
356 ['> 1.0.0', '>1.0.0'],
357 ['> 1.0.0', '>1.0.0'],
358 ['<= 2.0.0', '<=2.0.0'],
359 ['<= 2.0.0', '<=2.0.0'],
360 ['<= 2.0.0', '<=2.0.0'],
361 ['< 2.0.0', '<2.0.0-0'],
362 ['< 2.0.0', '<2.0.0-0'],
363 ['>=0.1.97', '>=0.1.97'],
364 ['>=0.1.97', '>=0.1.97'],
365 ['0.1.20 || 1.2.4', '0.1.20||1.2.4'],
366 ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'],
367 ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'],
368 ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'],
370 ['2.x.x', '>=2.0.0-0 <3.0.0-0'],
371 ['1.2.x', '>=1.2.0-0 <1.3.0-0'],
372 ['1.2.x || 2.x', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'],
373 ['1.2.x || 2.x', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'],
375 ['2.*.*', '>=2.0.0-0 <3.0.0-0'],
376 ['1.2.*', '>=1.2.0-0 <1.3.0-0'],
377 ['1.2.* || 2.*', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'],
379 ['2', '>=2.0.0-0 <3.0.0-0'],
380 ['2.3', '>=2.3.0-0 <2.4.0-0'],
381 ['~2.4', '>=2.4.0-0 <2.5.0-0'],
382 ['~2.4', '>=2.4.0-0 <2.5.0-0'],
383 ['~>3.2.1', '>=3.2.1-0 <3.3.0-0'],
384 ['~1', '>=1.0.0-0 <2.0.0-0'],
385 ['~>1', '>=1.0.0-0 <2.0.0-0'],
386 ['~> 1', '>=1.0.0-0 <2.0.0-0'],
387 ['~1.0', '>=1.0.0-0 <1.1.0-0'],
388 ['~ 1.0', '>=1.0.0-0 <1.1.0-0'],
389 ['^0', '>=0.0.0-0 <1.0.0-0'],
390 ['^ 1', '>=1.0.0-0 <2.0.0-0'],
391 ['^0.1', '>=0.1.0-0 <0.2.0-0'],
392 ['^1.0', '>=1.0.0-0 <2.0.0-0'],
393 ['^1.2', '>=1.2.0-0 <2.0.0-0'],
394 ['^0.0.1', '=0.0.1'],
395 ['^0.0.1-beta', '=0.0.1-beta'],
396 ['^0.1.2', '>=0.1.2-0 <0.2.0-0'],
397 ['^1.2.3', '>=1.2.3-0 <2.0.0-0'],
398 ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'],
401 ['>=1', '>=1.0.0-0'],
402 ['>= 1', '>=1.0.0-0'],
403 ['<1.2', '<1.2.0-0'],
404 ['< 1.2', '<1.2.0-0'],
405 ['1', '>=1.0.0-0 <2.0.0-0'],
406 ['>01.02.03', '>1.2.3', true],
408 ['~1.2.3beta', '>=1.2.3-beta <1.3.0-0', true],
409 ['~1.2.3beta', null],
410 ['^ 1.2 ^ 1', '>=1.2.0-0 <2.0.0-0 >=1.0.0-0 <2.0.0-0']
411 ].forEach(function(v) {
415 var found = validRange(pre, loose);
417 t.equal(found, wanted, 'validRange(' + pre + ') === ' + wanted);
423 test('\ncomparators test', function(t) {
424 // [range, comparators]
425 // turn range into a set of individual comparators
426 [['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]],
427 ['1.0.0', [['1.0.0']]],
428 ['>=*', [['>=0.0.0-0']]],
432 ['>=1.0.0', [['>=1.0.0']]],
433 ['>=1.0.0', [['>=1.0.0']]],
434 ['>=1.0.0', [['>=1.0.0']]],
435 ['>1.0.0', [['>1.0.0']]],
436 ['>1.0.0', [['>1.0.0']]],
437 ['<=2.0.0', [['<=2.0.0']]],
438 ['1', [['>=1.0.0-0', '<2.0.0-0']]],
439 ['<=2.0.0', [['<=2.0.0']]],
440 ['<=2.0.0', [['<=2.0.0']]],
441 ['<2.0.0', [['<2.0.0-0']]],
442 ['<2.0.0', [['<2.0.0-0']]],
443 ['>= 1.0.0', [['>=1.0.0']]],
444 ['>= 1.0.0', [['>=1.0.0']]],
445 ['>= 1.0.0', [['>=1.0.0']]],
446 ['> 1.0.0', [['>1.0.0']]],
447 ['> 1.0.0', [['>1.0.0']]],
448 ['<= 2.0.0', [['<=2.0.0']]],
449 ['<= 2.0.0', [['<=2.0.0']]],
450 ['<= 2.0.0', [['<=2.0.0']]],
451 ['< 2.0.0', [['<2.0.0-0']]],
452 ['<\t2.0.0', [['<2.0.0-0']]],
453 ['>=0.1.97', [['>=0.1.97']]],
454 ['>=0.1.97', [['>=0.1.97']]],
455 ['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]],
456 ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]],
457 ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]],
458 ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]],
459 ['||', [[''], ['']]],
460 ['2.x.x', [['>=2.0.0-0', '<3.0.0-0']]],
461 ['1.2.x', [['>=1.2.0-0', '<1.3.0-0']]],
462 ['1.2.x || 2.x', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]],
463 ['1.2.x || 2.x', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]],
465 ['2.*.*', [['>=2.0.0-0', '<3.0.0-0']]],
466 ['1.2.*', [['>=1.2.0-0', '<1.3.0-0']]],
467 ['1.2.* || 2.*', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]],
468 ['1.2.* || 2.*', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]],
470 ['2', [['>=2.0.0-0', '<3.0.0-0']]],
471 ['2.3', [['>=2.3.0-0', '<2.4.0-0']]],
472 ['~2.4', [['>=2.4.0-0', '<2.5.0-0']]],
473 ['~2.4', [['>=2.4.0-0', '<2.5.0-0']]],
474 ['~>3.2.1', [['>=3.2.1-0', '<3.3.0-0']]],
475 ['~1', [['>=1.0.0-0', '<2.0.0-0']]],
476 ['~>1', [['>=1.0.0-0', '<2.0.0-0']]],
477 ['~> 1', [['>=1.0.0-0', '<2.0.0-0']]],
478 ['~1.0', [['>=1.0.0-0', '<1.1.0-0']]],
479 ['~ 1.0', [['>=1.0.0-0', '<1.1.0-0']]],
480 ['~ 1.0.3', [['>=1.0.3-0', '<1.1.0-0']]],
481 ['~> 1.0.3', [['>=1.0.3-0', '<1.1.0-0']]],
482 ['<1', [['<1.0.0-0']]],
483 ['< 1', [['<1.0.0-0']]],
484 ['>=1', [['>=1.0.0-0']]],
485 ['>= 1', [['>=1.0.0-0']]],
486 ['<1.2', [['<1.2.0-0']]],
487 ['< 1.2', [['<1.2.0-0']]],
488 ['1', [['>=1.0.0-0', '<2.0.0-0']]],
489 ['1 2', [['>=1.0.0-0', '<2.0.0-0', '>=2.0.0-0', '<3.0.0-0']]],
490 ['1.2 - 3.4.5', [['>=1.2.0-0', '<=3.4.5']]],
491 ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0-0']]]
492 ].forEach(function(v) {
495 var found = toComparators(v[0]);
496 var jw = JSON.stringify(wanted);
497 t.equivalent(found, wanted, 'toComparators(' + pre + ') === ' + jw);
503 test('\nstrict vs loose version numbers', function(t) {
504 [['=1.2.3', '1.2.3'],
505 ['01.02.03', '1.2.3'],
506 ['1.2.3-beta.01', '1.2.3-beta.1'],
507 [' =1.2.3', '1.2.3'],
508 ['1.2.3foo', '1.2.3-foo']
509 ].forEach(function(v) {
512 t.throws(function() {
515 var lv = new SemVer(loose, true);
516 t.equal(lv.version, strict);
517 t.ok(eq(loose, strict, true));
518 t.throws(function() {
521 t.throws(function() {
522 new SemVer(strict).compare(loose);
528 test('\nstrict vs loose ranges', function(t) {
529 [['>=01.02.03', '>=1.2.3'],
530 ['~1.02.03beta', '>=1.2.3-beta <1.3.0-0']
531 ].forEach(function(v) {
534 t.throws(function() {
537 t.equal(new Range(loose, true).range, comps);
542 test('\nmax satisfying', function(t) {
543 [[['1.2.3', '1.2.4'], '1.2', '1.2.4'],
544 [['1.2.4', '1.2.3'], '1.2', '1.2.4'],
545 [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'],
546 [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true]
547 ].forEach(function(v) {
552 var actual = semver.maxSatisfying(versions, range, loose);
553 t.equal(actual, expect);