From 8fec4a8a2fb1944b1b9c96b0c4803a49e362c81a Mon Sep 17 00:00:00 2001 From: RezzedUp Date: Thu, 3 Feb 2022 16:56:24 -0600 Subject: [PATCH] Fix checked double supplier attempt test. --- .../java/com/rezzedup/util/exceptional/AttemptTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/rezzedup/util/exceptional/AttemptTests.java b/src/test/java/com/rezzedup/util/exceptional/AttemptTests.java index ad93e8d..35ee747 100644 --- a/src/test/java/com/rezzedup/util/exceptional/AttemptTests.java +++ b/src/test/java/com/rezzedup/util/exceptional/AttemptTests.java @@ -85,12 +85,14 @@ private void test(Attempt attempt, Function, Consumer maybe.assertIfResultExists(optional -> assertTrue(optional.isEmpty())); } - // Test a checked long supplier that throws an ArithmeticException (divides by zero) + // Test a checked long supplier that throws an ArithmeticException { Result maybe = new Result<>(); assertions.apply(ArithmeticException.class).accept(() -> - maybe.result = attempt.getAsDouble(() -> 1.0 / 0) // can't use 0.0 otherwise we end up with Infinity + // The exception must be thrown manually because apparently + // division by zero is perfectly legal in floating-point land... + maybe.result = attempt.getAsDouble(() -> { throw new ArithmeticException(); }) ); maybe.assertIfResultExists(optional -> assertTrue(optional.isEmpty()));