dud: A dub replacement

Sebastiaan Koppe mail at skoppe.eu
Thu Jan 23 20:50:09 UTC 2020


On Thursday, 23 January 2020 at 17:05:10 UTC, Robert Schadek 
wrote:
> DESTROY!

Tried:

---
unittest {
   immutable SemVer v1 = SemVer(1,1,1);
   immutable SemVer v2 = SemVer(2,2,2);
   immutable SemVer v3 = SemVer(3,3,3);
   immutable SemVer v4 = SemVer(4,4,4);
   immutable VersionRange a = VersionRange(v1, Inclusive.yes, v2, 
Inclusive.yes);
   immutable VersionRange b = VersionRange(v3, Inclusive.yes, v4, 
Inclusive.yes);
   immutable VersionRange c = VersionRange(v2, Inclusive.yes, v3, 
Inclusive.yes);

   assert(intersectionOf(a, invert(a)).ranges.length == 0);
   assert(intersectionOf(a, a) == a);
   assert(intersectionOf(a, b) != a);
   assert(intersectionOf(a, b) != b);
   assert(intersectionOf(b, a) != a);
   assert(intersectionOf(b, a) != b);
   assert(intersectionOf(invert(a), invert(a)) == invert(a));
   assert(invert(intersectionOf(a, invert(b))) == 
invert(intersectionOf(a,a)));

   auto add(T, P)(T a, P b) {
	return invert(intersectionOf(invert(a), invert(b)));
   }
   auto remove(T, P)(T a, P b) {
	return intersectionOf(a, invert(b));
   }

   assert(add(a,b) == add(b,a));

   assert(invert(invert(a)) == add(intersectionOf(a,c), 
remove(a,c)));
   assert(differenceOf(a, a).ranges.length == 0);
   assert(invert(intersectionOf(invert(a), invert(a))) == 
invert(invert(a)));
   assert(invert(invert(differenceOf(a, invert(a)))) == 
invert(invert(a)));
   assert(invert(invert(intersectionOf(a, c))) == 
invert(invert(remove(a, remove(a, c)))));
}
---

Everything green. Nice work.

Haven't tried Inclusive.no yet. I'll leave that to someone else.


More information about the Digitalmars-d-announce mailing list