Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Paul Backus"
],
"dependencies": {
"sumtype": ">=0.6.2 <1.0.0"
"sumtype": "1.1.4"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependency should use ~>1.0 or similar to allow applications and libraries depending on this library to choose sumtype versions more freely

~>1.0 is equal to >=1.0.0 <2.0.0

},
"description": "Error handling that bundles exceptions with return values",
"copyright": "Copyright © 2018, Paul Backus",
Expand Down
2 changes: 1 addition & 1 deletion dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"fileVersion": 1,
"versions": {
"sumtype": "0.8.4"
"sumtype": "1.1.4"
}
}
16 changes: 8 additions & 8 deletions src/expectations.d
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ template map(alias fun)
}

@safe unittest {
import std.math: approxEqual;
import std.math: isClose;

Expected!int x = 123;
Expected!int y = new Exception("oops");
Expand All @@ -450,12 +450,12 @@ template map(alias fun)
x.map!half;
}));

assert(x.map!half.value.approxEqual(61.5));
assert(x.map!half.value.isClose(61.5));
assert(y.map!half.error.msg == "oops");

alias mapHalf = map!half;

assert(mapHalf(Expected!int(123)).value.approxEqual(61.5));
assert(mapHalf(Expected!int(123)).value.isClose(61.5));
}

@safe unittest {
Expand Down Expand Up @@ -502,7 +502,7 @@ template flatMap(alias fun)
}

@safe unittest {
import std.math: approxEqual;
import std.math: isClose;

Expected!int x = 123;
Expected!int y = 0;
Expand All @@ -521,17 +521,17 @@ template flatMap(alias fun)
x.flatMap!recip;
}));

assert(x.flatMap!recip.value.approxEqual(1.0/123));
assert(x.flatMap!recip.value.isClose(1.0/123));
assert(y.flatMap!recip.error.msg == "Division by zero");
assert(z.flatMap!recip.error.msg == "oops");

alias flatMapRecip = flatMap!recip;

assert(flatMapRecip(Expected!int(123)).value.approxEqual(1.0/123));
assert(flatMapRecip(Expected!int(123)).value.isClose(1.0/123));
}

@safe unittest {
import std.math: approxEqual;
import std.math: isClose;

Expected!(int, string) x = 123;
Expected!(int, string) y = 0;
Expand All @@ -550,7 +550,7 @@ template flatMap(alias fun)
x.flatMap!recip;
}));

assert(x.flatMap!recip.value.approxEqual(1.0/123));
assert(x.flatMap!recip.value.isClose(1.0/123));
assert(y.flatMap!recip.error == "Division by zero");
assert(z.flatMap!recip.error == "oops");
}
Expand Down