Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: test/version_union_test.dart

Issue 2045803002: Add VersionConstraint.difference(). (Closed) Base URL: git@github.com:dart-lang/pub_semver@master
Patch Set: Code review changes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/version_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
6 6
7 import 'package:pub_semver/pub_semver.dart'; 7 import 'package:pub_semver/pub_semver.dart';
8 8
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 test("drops parts that don't match", () { 343 test("drops parts that don't match", () {
344 expect(union.intersect(new VersionConstraint.unionOf([ 344 expect(union.intersect(new VersionConstraint.unionOf([
345 v003, 345 v003,
346 new VersionRange(min: v072, max: v080), 346 new VersionRange(min: v072, max: v080),
347 new VersionRange(min: v080, max: v123) 347 new VersionRange(min: v080, max: v123)
348 ])), equals(new VersionRange(min: v072, max: v080))); 348 ])), equals(new VersionRange(min: v072, max: v080)));
349 }); 349 });
350 }); 350 });
351 }); 351 });
352
353 group("difference()", () {
354 test("ignores ranges that don't intersect", () {
355 expect(new VersionConstraint.unionOf([
356 new VersionRange(min: v072, max: v080),
357 new VersionRange(min: v123, max: v130)
358 ]).difference(new VersionConstraint.unionOf([
359 new VersionRange(min: v003, max: v010),
360 new VersionRange(min: v080, max: v123),
361 new VersionRange(min: v140)
362 ])), equals(new VersionConstraint.unionOf([
363 new VersionRange(min: v072, max: v080),
364 new VersionRange(min: v123, max: v130)
365 ])));
366 });
367
368 test("removes overlapping portions", () {
369 expect(new VersionConstraint.unionOf([
370 new VersionRange(min: v010, max: v080),
371 new VersionRange(min: v123, max: v130)
372 ]).difference(new VersionConstraint.unionOf([
373 new VersionRange(min: v003, max: v072),
374 new VersionRange(min: v124)
375 ])), equals(new VersionConstraint.unionOf([
376 new VersionRange(min: v072, max: v080, includeMin: true),
377 new VersionRange(min: v123, max: v124, includeMax: true)
378 ])));
379 });
380
381 test("removes multiple portions from the same range", () {
382 expect(new VersionConstraint.unionOf([
383 new VersionRange(min: v010, max: v114),
384 new VersionRange(min: v130, max: v200)
385 ]).difference(new VersionConstraint.unionOf([v072, v080])),
386 equals(new VersionConstraint.unionOf([
387 new VersionRange(min: v010, max: v072),
388 new VersionRange(min: v072, max: v080),
389 new VersionRange(min: v080, max: v114),
390 new VersionRange(min: v130, max: v200)
391 ])));
392 });
393
394 test("removes the same range from multiple ranges", () {
395 expect(new VersionConstraint.unionOf([
396 new VersionRange(min: v010, max: v072),
397 new VersionRange(min: v080, max: v123),
398 new VersionRange(min: v124, max: v130),
399 new VersionRange(min: v200, max: v234),
400 new VersionRange(min: v250, max: v300)
401 ]).difference(new VersionRange(min: v114, max: v201)),
402 equals(new VersionConstraint.unionOf([
403 new VersionRange(min: v010, max: v072),
404 new VersionRange(min: v080, max: v114, includeMax: true),
405 new VersionRange(min: v201, max: v234, includeMin: true),
406 new VersionRange(min: v250, max: v300)
407 ])));
408 });
409 });
352 } 410 }
OLDNEW
« no previous file with comments | « test/version_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698