From 02f9b2fc4af8bb1e2d9ad58cd680168f79af8055 Mon Sep 17 00:00:00 2001 From: Jenny Pollack Date: Wed, 25 Aug 2021 11:09:59 +0200 Subject: [PATCH 1/2] add assertFail --- demo/demo.sol | 5 +++++ src/test.sol | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/demo/demo.sol b/demo/demo.sol index d3a7d81..665f3c9 100644 --- a/demo/demo.sol +++ b/demo/demo.sol @@ -86,6 +86,11 @@ contract DemoTest is DSTest { emit log("\n"); assertTrue(false, err); + emit log("## assertFalse(bool)\n"); + assertFalse(true); + emit log("\n"); + assertFalse(true, err); + emit log("\n## assertEq(address,address)\n"); assertEq(address(this), msg.sender); emit log("\n"); diff --git a/src/test.sol b/src/test.sol index 96d3c15..e0a28ef 100644 --- a/src/test.sol +++ b/src/test.sol @@ -69,6 +69,19 @@ contract DSTest { } } + function assertFalse(bool condition) internal { + if (condition) { + emit log("Error: Assertion True"); + fail(); + } + } + function assertFalse(bool condition, string memory err) internal { + if (condition) { + emit log_named_string("Error", err); + assertFalse(condition); + } + } + function assertEq(address a, address b) internal { if (a != b) { emit log("Error: a == b not satisfied [address]"); From 2d2cb9f7c61ccf112e3dddb42ba0c5fd2f61a7f6 Mon Sep 17 00:00:00 2001 From: Jenny Pollack Date: Wed, 25 Aug 2021 12:29:21 +0200 Subject: [PATCH 2/2] edit log Co-authored-by: David Terry <6689924+d-xo@users.noreply.github.com> --- src/test.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test.sol b/src/test.sol index e0a28ef..5ea9830 100644 --- a/src/test.sol +++ b/src/test.sol @@ -71,7 +71,7 @@ contract DSTest { function assertFalse(bool condition) internal { if (condition) { - emit log("Error: Assertion True"); + emit log("Error: Assertion Failed"); fail(); } }