Skip to content
Merged
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ test:
-dapp --use solc:0.5.17 build
-dapp --use solc:0.6.12 build
-dapp --use solc:0.7.5 build
-dapp --use solc:0.8.6 build

demo:
DAPP_SRC=demo dapp --use solc:0.7.5 build
DAPP_SRC=demo dapp --use solc:0.8.6 build
-hevm dapp-test --verbose 3

.PHONY: test demo
29 changes: 29 additions & 0 deletions src/test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract DSTest {
event log_named_uint (string key, uint val);
event log_named_bytes (string key, bytes val);
event log_named_string (string key, string val);
event log_named_bool (string key, bool val);

bool public IS_TEST = true;
bool public failed;
Expand Down Expand Up @@ -69,6 +70,20 @@ contract DSTest {
}
}

function assertFalse(bool condition) internal {
if (condition) {
emit log("Error: Assertion Failed");
fail();
}
}

function assertFalse(bool condition, string memory err) internal {
if (condition) {
emit log_named_string("Error", err);
assertTrue(condition);
}
}

function assertEq(address a, address b) internal {
if (a != b) {
emit log("Error: a == b not satisfied [address]");
Expand Down Expand Up @@ -161,6 +176,20 @@ contract DSTest {
assertEqDecimal(a, b, decimals);
}
}
function assertEq(bool a, bool b) internal {
if (a != b) {
emit log("Error: a == b not satisfied [bool]");
emit log_named_bool(" Expected", b);
emit log_named_bool(" Actual", a);
fail();
}
}
function assertEq(bool a, bool b, string memory err) internal {
if (a != b) {
emit log_named_string("Error", err);
assertEq(a, b);
}
}

function assertGt(uint a, uint b) internal {
if (a <= b) {
Expand Down