From 64e4b1e48daf0944d60b2c991daa53afba707f01 Mon Sep 17 00:00:00 2001 From: smol-ninja Date: Thu, 21 Mar 2024 23:33:47 +0000 Subject: [PATCH] build: update forge-std to v1.8.1 build: remove @prb/test dependency test: declare some functions as pure --- .solhint.json | 1 + bun.lockb | Bin 42095 -> 41648 bytes package.json | 6 +- remappings.txt | 1 - test/Base.t.sol | 16 +++- test/fuzz/casting/CastingUint128.t.sol | 8 +- test/fuzz/casting/CastingUint256.t.sol | 8 +- test/fuzz/casting/CastingUint40.t.sol | 8 +- test/fuzz/sd1x18/casting/Casting.t.sol | 18 ++--- test/fuzz/sd59x18/casting/Casting.t.sol | 22 +++--- test/fuzz/sd59x18/helpers/Helpers.t.sol | 38 +++++----- test/fuzz/sd59x18/math/pow/pow.t.sol | 8 +- test/fuzz/ud2x18/casting/Casting.t.sol | 18 ++--- test/fuzz/ud60x18/casting/Casting.t.sol | 20 ++--- test/fuzz/ud60x18/helpers/Helpers.t.sol | 36 ++++----- test/fuzz/ud60x18/math/pow/pow.t.sol | 8 +- test/unit/sd59x18/math/abs/abs.t.sol | 2 +- test/unit/sd59x18/math/avg/avg.t.sol | 2 +- test/unit/sd59x18/math/ceil/ceil.t.sol | 2 +- test/unit/sd59x18/math/exp/exp.t.sol | 2 +- test/unit/sd59x18/math/exp2/exp2.t.sol | 2 +- test/unit/sd59x18/math/floor/floor.t.sol | 2 +- test/unit/sd59x18/math/frac/frac.t.sol | 2 +- test/unit/sd59x18/math/pow/pow.t.sol | 10 +-- test/unit/sd59x18/math/powu/powu.t.sol | 2 +- test/unit/sd59x18/math/sqrt/sqrt.t.sol | 2 +- test/unit/ud60x18/UD60x18.t.sol | 8 +- test/unit/ud60x18/math/avg/avg.t.sol | 2 +- test/unit/ud60x18/math/ceil/ceil.t.sol | 2 +- test/unit/ud60x18/math/exp/exp.t.sol | 2 +- test/unit/ud60x18/math/exp2/exp2.t.sol | 2 +- test/unit/ud60x18/math/floor/floor.t.sol | 2 +- test/unit/ud60x18/math/frac/frac.t.sol | 2 +- test/unit/ud60x18/math/pow/pow.t.sol | 10 +-- test/unit/ud60x18/math/powu/powu.t.sol | 2 +- test/unit/ud60x18/math/sqrt/sqrt.t.sol | 2 +- test/utils/Assertions.sol | 92 +++++++++++------------ 37 files changed, 191 insertions(+), 179 deletions(-) diff --git a/.solhint.json b/.solhint.json index 36aff3dd..13fad6ea 100644 --- a/.solhint.json +++ b/.solhint.json @@ -7,6 +7,7 @@ "contract-name-camelcase": "off", "func-name-mixedcase": "off", "func-visibility": ["error", { "ignoreConstructors": true }], + "gas-custom-errors": "off", "max-line-length": ["error", 132], "no-console": "off", "no-global-import": "off", diff --git a/bun.lockb b/bun.lockb index 0a9f0669d845e6403d5d60d69fd38a9f1b7eedcf..9fda8c2743bdf44ade41cd56ce07e1b264d1ce6a 100755 GIT binary patch delta 6699 zcmeHLc~n$a(toen`XS9C5P6^ig1fW=ViQrCxCL1hjf!Ag8YFBe27F<59M zCKxeM6QiT{9G67nGI2C<<^(fF#Vsej2e zb?erxTX%W&-D%yPle(9TJ%gs#ubE9Nhrjspo!Y9mpE5Zr&wIT;XZg>U9-isyx;l1E zSc9OHlA6p=UBBX*iZILPV0a3Gz08tRl!xyoC+(tB`R|E>;Dz>D&>etR0=EO+3qJQ- z=AyP&0yE#&RS*ooQ-Qg?q2_+5ZLpgl_=D&P8~_{)>;qhyH>*6)DhSQ)f*^sOXDKQw zEG-inVFc4f#nUaN1%hw_v^QvPy*k(|C${FI0p)wptbbPF?7~@40Hp9+z=u&bd$vT*3YhKG?!?Oq&&KQW^yNP+wJn#-EutubfA8_frk&i+1){0B{KK3+RVW zdpR&0ytKVaKS%R)CO;iSdHA=0*}o6zxUPfkE(YdF9fDqN-3`q2>L*ls5ilD&6zhv& z?cIPo0q0q*#n!02igBuLHB;Z#pON8w2IP;+&Xec3F|NzaUs?U7{NtOE3y#j|e)$_)O2Ew>t9;I% zcQ2tm?(uZby~6j(lzwCP^**$wa`}akV*H9EddVZ%kO*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S8l^q;sP8Lypfr-TI@4uX|+_jEIFXkNq)Y=!PX2bj~^appyINC z?#aa^xl!|T%JSuxGD~S0-CP#xf-5BQTRy^rx2>|g#bn(UU|+sG+1({hA8SAU>^_OU zUJ*vm)Q8#MTzgAJeVz`px2`|$8W5w8WBugZoLoy`RDMBTej%WYvR3x8f6#D6r2Y+o zE=V|~G_0VI2DN?9*0)vk_2y7&TdA?Hd&x)aF%)wJ6PPn>QIXDDFfyzN?yUqI6&aby#N3J diff --git a/package.json b/package.json index d84ec326..b0dd7921 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "url": "https://github.com/PaulRBerg/prb-math/issues" }, "devDependencies": { - "@prb/test": "0.6.5", - "forge-std": "github:foundry-rs/forge-std#v1.7.4", + "forge-std": "github:foundry-rs/forge-std#v1.8.1", "prettier": "^3.1.1", "solhint": "^4.0.0" }, @@ -43,6 +42,7 @@ "lint": "bun run lint:sol && bun run prettier:check", "lint:sol": "forge fmt --check && bun solhint \"{src,test}/**/*.sol\"", "prettier:check": "prettier --check \"**/*.{json,md,yml}\"", - "prettier:write": "prettier --write \"**/*.{json,md,yml}\"" + "prettier:write": "prettier --write \"**/*.{json,md,yml}\"", + "test": "forge test" } } diff --git a/remappings.txt b/remappings.txt index 3cddfe74..bcc8cde0 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,2 +1 @@ -@prb/test/=node_modules/@prb/test/ forge-std/=node_modules/forge-std/ diff --git a/test/Base.t.sol b/test/Base.t.sol index 6e25221d..d44bb822 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -1,14 +1,15 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.19 <0.9.0; -import { PRBTest } from "@prb/test/src/PRBTest.sol"; +import { StdAssertions } from "forge-std/src/StdAssertions.sol"; import { StdCheats } from "forge-std/src/StdCheats.sol"; +import { Vm } from "forge-std/src/Vm.sol"; import { PRBMathAssertions } from "./utils/Assertions.sol"; import { PRBMathUtils } from "./utils/Utils.sol"; /// @notice Base test contract with common logic needed by all tests. -abstract contract Base_Test is PRBTest, StdCheats, PRBMathAssertions, PRBMathUtils { +abstract contract Base_Test is StdAssertions, StdCheats, PRBMathAssertions, PRBMathUtils { /*////////////////////////////////////////////////////////////////////////// STRUCTS //////////////////////////////////////////////////////////////////////////*/ @@ -19,14 +20,25 @@ abstract contract Base_Test is PRBTest, StdCheats, PRBMathAssertions, PRBMathUti address eve; } + /*////////////////////////////////////////////////////////////////////////// + CHEATCODES + //////////////////////////////////////////////////////////////////////////*/ + + /// @dev An instance of the Foundry VM, which contains cheatcodes for testing. + Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); + /*////////////////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////////////////*/ + int256 internal constant MAX_INT256 = type(int256).max; + uint128 internal constant MAX_UINT128 = type(uint128).max; uint128 internal constant MAX_UINT40 = type(uint40).max; + int256 internal constant MIN_INT256 = type(int256).min; + /*////////////////////////////////////////////////////////////////////////// VARIABLES //////////////////////////////////////////////////////////////////////////*/ diff --git a/test/fuzz/casting/CastingUint128.t.sol b/test/fuzz/casting/CastingUint128.t.sol index e1b7a6f2..efe10ed9 100644 --- a/test/fuzz/casting/CastingUint128.t.sol +++ b/test/fuzz/casting/CastingUint128.t.sol @@ -25,14 +25,14 @@ contract CastingUint128_Test is Base_Test { x.intoSD1x18(); } - function testFuzz_intoSD1x18(uint128 x) external { + function testFuzz_intoSD1x18(uint128 x) external pure { x = boundUint128(x, 0, uint128(uint64(uMAX_SD1x18))); SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(uint64(x))); assertEq(actual, expected, "uint128 intoSD1x18"); } - function testFuzz_intoSD59x18(uint128 x) external { + function testFuzz_intoSD59x18(uint128 x) external pure { SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(uint256(x))); assertEq(actual, expected, "uint128 intoSD59x18"); @@ -44,14 +44,14 @@ contract CastingUint128_Test is Base_Test { x.intoUD2x18(); } - function testFuzz_intoUD2x18(uint128 x) external { + function testFuzz_intoUD2x18(uint128 x) external pure { x = boundUint128(x, 0, uint128(uMAX_UD2x18)); UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(x)); assertEq(actual, expected, "uint128 intoUD2x18"); } - function testFuzz_intoUD60x18(uint128 x) external { + function testFuzz_intoUD60x18(uint128 x) external pure { UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(uint256(x)); assertEq(actual, expected, "uint128 intoUD60x18"); diff --git a/test/fuzz/casting/CastingUint256.t.sol b/test/fuzz/casting/CastingUint256.t.sol index 84ff16c1..ffcc2961 100644 --- a/test/fuzz/casting/CastingUint256.t.sol +++ b/test/fuzz/casting/CastingUint256.t.sol @@ -27,7 +27,7 @@ contract CastingUint256_Test is Base_Test { x.intoSD1x18(); } - function testFuzz_intoSD1x18(uint256 x) external { + function testFuzz_intoSD1x18(uint256 x) external pure { x = _bound(x, 0, uint64(uMAX_SD1x18)); SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(uint64(x))); @@ -40,7 +40,7 @@ contract CastingUint256_Test is Base_Test { x.intoSD59x18(); } - function testFuzz_intoSD59x18(uint256 x) external { + function testFuzz_intoSD59x18(uint256 x) external pure { x = _bound(x, 0, uint256(uMAX_SD59x18)); SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(uint256(x))); @@ -53,14 +53,14 @@ contract CastingUint256_Test is Base_Test { x.intoUD2x18(); } - function testFuzz_intoUD2x18(uint256 x) external { + function testFuzz_intoUD2x18(uint256 x) external pure { x = _bound(x, 0, uint256(uMAX_UD2x18)); UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(x)); assertEq(actual, expected, "uint256 intoUD2x18"); } - function testFuzz_intoUD60x18(uint256 x) external { + function testFuzz_intoUD60x18(uint256 x) external pure { UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(x); assertEq(actual, expected, "uint256 intoUD60x18"); diff --git a/test/fuzz/casting/CastingUint40.t.sol b/test/fuzz/casting/CastingUint40.t.sol index 2bbeaad9..ee456676 100644 --- a/test/fuzz/casting/CastingUint40.t.sol +++ b/test/fuzz/casting/CastingUint40.t.sol @@ -13,25 +13,25 @@ import { Base_Test } from "../../Base.t.sol"; contract CastingUint40_Test is Base_Test { using CastingUint40 for uint40; - function testFuzz_intoSD1x18(uint40 x) external { + function testFuzz_intoSD1x18(uint40 x) external pure { SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(uint64(x))); assertEq(actual, expected, "uint40 intoSD1x18"); } - function testFuzz_intoSD59x18(uint40 x) external { + function testFuzz_intoSD59x18(uint40 x) external pure { SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(uint256(x))); assertEq(actual, expected, "uint40 intoSD59x18"); } - function testFuzz_intoUD2x18(uint40 x) external { + function testFuzz_intoUD2x18(uint40 x) external pure { UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(x)); assertEq(actual, expected, "uint40 intoUD2x18"); } - function testFuzz_intoUD60x18(uint40 x) external { + function testFuzz_intoUD60x18(uint40 x) external pure { UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(uint256(x)); assertEq(actual, expected, "uint40 intoUD60x18"); diff --git a/test/fuzz/sd1x18/casting/Casting.t.sol b/test/fuzz/sd1x18/casting/Casting.t.sol index ab4c2af7..f72206e1 100644 --- a/test/fuzz/sd1x18/casting/Casting.t.sol +++ b/test/fuzz/sd1x18/casting/Casting.t.sol @@ -20,7 +20,7 @@ import { Base_Test } from "../../../Base.t.sol"; /// @dev Collection of tests for the casting functions available in SD1x18. contract Casting_Fuzz_Test is Base_Test { - function testFuzz_IntoSD59x18(SD1x18 x) external { + function testFuzz_IntoSD59x18(SD1x18 x) external pure { SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(x.unwrap())); assertEq(actual, expected, "SD1x18 intoSD59x18"); @@ -32,7 +32,7 @@ contract Casting_Fuzz_Test is Base_Test { x.intoUD2x18(); } - function testFuzz_IntoUD2x18(SD1x18 x) external { + function testFuzz_IntoUD2x18(SD1x18 x) external pure { x = _bound(x, 0, MAX_SD1x18); UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(x.unwrap())); @@ -45,7 +45,7 @@ contract Casting_Fuzz_Test is Base_Test { x.intoUD60x18(); } - function testFuzz_IntoUD60x18(SD1x18 x) external { + function testFuzz_IntoUD60x18(SD1x18 x) external pure { x = _bound(x, 0, MAX_SD1x18); UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(uint64(x.unwrap())); @@ -58,7 +58,7 @@ contract Casting_Fuzz_Test is Base_Test { x.intoUint256(); } - function testFuzz_IntoUint256(SD1x18 x) external { + function testFuzz_IntoUint256(SD1x18 x) external pure { x = _bound(x, 0, MAX_SD1x18); uint256 actual = x.intoUint256(); uint256 expected = uint64(x.unwrap()); @@ -71,7 +71,7 @@ contract Casting_Fuzz_Test is Base_Test { x.intoUint128(); } - function testFuzz_IntoUint128(SD1x18 x) external { + function testFuzz_IntoUint128(SD1x18 x) external pure { x = _bound(x, 0, MAX_SD1x18); uint128 actual = x.intoUint128(); uint128 expected = uint64(x.unwrap()); @@ -90,26 +90,26 @@ contract Casting_Fuzz_Test is Base_Test { x.intoUint40(); } - function testFuzz_IntoUint40(SD1x18 x) external { + function testFuzz_IntoUint40(SD1x18 x) external pure { x = _bound(x, 0, int64(uint64(MAX_UINT40))); uint40 actual = x.intoUint40(); uint40 expected = uint40(uint64(x.unwrap())); assertEq(actual, expected, "SD1x18 intoUint40"); } - function testFuzz_sd1x18(int64 x) external { + function testFuzz_sd1x18(int64 x) external pure { SD1x18 actual = sd1x18(x); SD1x18 expected = SD1x18.wrap(x); assertEq(actual, expected, "sd1x18"); } - function testFuzz_Unwrap(SD1x18 x) external { + function testFuzz_Unwrap(SD1x18 x) external pure { int64 actual = x.unwrap(); int64 expected = SD1x18.unwrap(x); assertEq(actual, expected, "SD1x18 unwrap"); } - function testFuzz_Wrap(int64 x) external { + function testFuzz_Wrap(int64 x) external pure { SD1x18 actual = wrap(x); SD1x18 expected = SD1x18.wrap(x); assertEq(actual, expected, "SD1x18 wrap"); diff --git a/test/fuzz/sd59x18/casting/Casting.t.sol b/test/fuzz/sd59x18/casting/Casting.t.sol index e2e70124..402e3d79 100644 --- a/test/fuzz/sd59x18/casting/Casting.t.sol +++ b/test/fuzz/sd59x18/casting/Casting.t.sol @@ -26,7 +26,7 @@ import { Base_Test } from "../../../Base.t.sol"; /// @dev Collection of tests for the casting functions available in SD59x18. contract SD59x18_Casting_Fuzz_Test is Base_Test { - function testFuzz_IntoInt256(SD59x18 x) external { + function testFuzz_IntoInt256(SD59x18 x) external pure { int256 actual = x.intoInt256(); int256 expected = SD59x18.unwrap(x); assertEq(actual, expected, "SD59x18 intoInt256"); @@ -44,7 +44,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoSD1x18(); } - function testFuzz_IntoSD1x18(SD59x18 x) external { + function testFuzz_IntoSD1x18(SD59x18 x) external pure { x = _bound(x, uMIN_SD1x18, uMAX_SD1x18); SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(x.unwrap())); @@ -63,7 +63,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoUD2x18(); } - function testFuzz_IntoUD2x18(SD59x18 x) external { + function testFuzz_IntoUD2x18(SD59x18 x) external pure { x = _bound(x, 0, int256(uint256(uMAX_UD2x18))); UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(uint256(x.unwrap()))); @@ -76,7 +76,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoUD60x18(); } - function testFuzz_IntoUD60x18(SD59x18 x) external { + function testFuzz_IntoUD60x18(SD59x18 x) external pure { x = _bound(x, 0, MAX_SD59x18); UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(uint256(x.unwrap())); @@ -95,7 +95,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoUint128(); } - function testFuzz_IntoUint128(SD59x18 x) external { + function testFuzz_IntoUint128(SD59x18 x) external pure { x = _bound(x, 0, int256(uint256(MAX_UINT128))); uint128 actual = x.intoUint128(); uint128 expected = uint128(uint256(x.unwrap())); @@ -108,7 +108,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoUint256(); } - function testFuzz_IntoUint256(SD59x18 x) external { + function testFuzz_IntoUint256(SD59x18 x) external pure { x = _bound(x, 0, MAX_SD59x18); uint256 actual = x.intoUint256(); uint256 expected = uint256(x.unwrap()); @@ -127,32 +127,32 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test { x.intoUint40(); } - function testFuzz_IntoUint40(SD59x18 x) external { + function testFuzz_IntoUint40(SD59x18 x) external pure { x = _bound(x, 0, int256(uint256(MAX_UINT40))); uint40 actual = x.intoUint40(); uint40 expected = uint40(uint256(x.unwrap())); assertEq(actual, expected, "SD59x18 intoUint40"); } - function testFuzz_Sd(int256 x) external { + function testFuzz_Sd(int256 x) external pure { SD59x18 actual = sd(x); SD59x18 expected = SD59x18.wrap(x); assertEq(actual, expected, "sd"); } - function testFuzz_sd59x18(int256 x) external { + function testFuzz_sd59x18(int256 x) external pure { SD59x18 actual = sd59x18(x); SD59x18 expected = SD59x18.wrap(x); assertEq(actual, expected, "sd59x18"); } - function testFuzz_Unwrap(SD59x18 x) external { + function testFuzz_Unwrap(SD59x18 x) external pure { int256 actual = x.unwrap(); int256 expected = SD59x18.unwrap(x); assertEq(actual, expected, "SD59x18 unwrap"); } - function testFuzz_Wrap(int256 x) external { + function testFuzz_Wrap(int256 x) external pure { SD59x18 actual = wrap(x); SD59x18 expected = SD59x18.wrap(x); assertEq(actual, expected, "SD59x18 wrap"); diff --git a/test/fuzz/sd59x18/helpers/Helpers.t.sol b/test/fuzz/sd59x18/helpers/Helpers.t.sol index 6dbb75a4..319d7a86 100644 --- a/test/fuzz/sd59x18/helpers/Helpers.t.sol +++ b/test/fuzz/sd59x18/helpers/Helpers.t.sol @@ -32,7 +32,7 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { int256 internal constant HALF_MAX_INT256 = MAX_INT256 / 2; int256 internal constant HALF_MIN_INT256 = MIN_INT256 / 2; - function testFuzz_Add(SD59x18 x, SD59x18 y) external { + function testFuzz_Add(SD59x18 x, SD59x18 y) external pure { x = _bound(x, HALF_MIN_INT256, HALF_MAX_INT256); y = _bound(y, HALF_MIN_INT256, HALF_MAX_INT256); SD59x18 expected = sd(x.unwrap() + y.unwrap()); @@ -40,86 +40,86 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { assertEq(x + y, expected, "SD59x18 +"); } - function testFuzz_And(int256 x, int256 y) external { + function testFuzz_And(int256 x, int256 y) external pure { SD59x18 expected = sd(x & y); assertEq(and(sd(x), y), expected, "SD59x18 and"); assertEq(sd(x) & sd(y), expected, "SD59x18 &"); } - function testFuzz_Eq(int256 x) external { + function testFuzz_Eq(int256 x) external pure { int256 y = x; assertTrue(eq(sd(x), sd(y)), "SD59x18 eq"); assertTrue(sd(x) == sd(y), "SD59x18 =="); } - function testFuzz_Gt(int256 x, int256 y) external { + function testFuzz_Gt(int256 x, int256 y) external pure { vm.assume(x > y); assertTrue(gt(sd(x), sd(y)), "SD59x18 gt"); assertTrue(sd(x) > sd(y), "SD59x18 >"); } - function testFuzz_Gte(int256 x, int256 y) external { + function testFuzz_Gte(int256 x, int256 y) external pure { vm.assume(x >= y); assertTrue(gte(sd(x), sd(y)), "SD59x18 gte"); assertTrue(sd(x) >= sd(y), "SD59x18 >="); } - function testFuzz_IsZero(SD59x18 x) external { + function testFuzz_IsZero(SD59x18 x) external pure { bool actual = isZero(x); bool expected = x == sd(0); assertEq(actual, expected, "SD59x18 isZero"); } - function testFuzz_Lshift(int256 x, uint256 y) external { + function testFuzz_Lshift(int256 x, uint256 y) external pure { _bound(y, 0, 512); SD59x18 expected = sd(x << y); assertEq(lshift(sd(x), y), expected, "SD59x18 lshift"); } - function testFuzz_Lt(int256 x, int256 y) external { + function testFuzz_Lt(int256 x, int256 y) external pure { vm.assume(x < y); assertTrue(lt(sd(x), sd(y)), "SD59x18 lt"); assertTrue(sd(x) < sd(y), "SD59x18 <"); } - function testFuzz_Lte(int256 x, int256 y) external { + function testFuzz_Lte(int256 x, int256 y) external pure { vm.assume(x <= y); assertTrue(lte(sd(x), sd(y)), "SD59x18 lte"); assertTrue(sd(x) <= sd(y), "SD59x18 <="); } - function testFuzz_Mod(int256 x, int256 y) external { + function testFuzz_Mod(int256 x, int256 y) external pure { vm.assume(y != 0); SD59x18 expected = sd(x % y); assertEq(mod(sd(x), sd(y)), expected, "SD59x18 mod"); assertEq(sd(x) % sd(y), expected, "SD59x18 %"); } - function testFuzz_Neq(int256 x, int256 y) external { + function testFuzz_Neq(int256 x, int256 y) external pure { vm.assume(x != y); assertTrue(neq(sd(x), sd(y)), "SD59x18 neq"); assertTrue(sd(x) != sd(y), "SD59x18 !="); } - function testFuzz_Not(int256 x) external { + function testFuzz_Not(int256 x) external pure { SD59x18 expected = sd(~x); assertEq(not(sd(x)), expected, "SD59x18 not"); assertEq(~sd(x), expected, "SD59x18 ~"); } - function testFuzz_Or(int256 x, int256 y) external { + function testFuzz_Or(int256 x, int256 y) external pure { SD59x18 expected = sd(x | y); assertEq(or(sd(x), sd(y)), expected, "SD59x18 or"); assertEq(sd(x) | sd(y), expected, "SD59x18 |"); } - function testFuzz_Rshift(int256 x, uint256 y) external { + function testFuzz_Rshift(int256 x, uint256 y) external pure { _bound(y, 0, 512); SD59x18 expected = sd(x >> y); assertEq(rshift(sd(x), y), expected, "SD59x18 rshift"); } - function testFuzz_Sub(SD59x18 x, SD59x18 y) external { + function testFuzz_Sub(SD59x18 x, SD59x18 y) external pure { x = _bound(x, HALF_MIN_INT256, HALF_MAX_INT256); y = _bound(y, HALF_MIN_INT256, HALF_MAX_INT256); SD59x18 expected = sd(x.unwrap() - y.unwrap()); @@ -127,7 +127,7 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { assertEq(x - y, expected, "SD59x18 -"); } - function testFuzz_Unary(int256 x) external { + function testFuzz_Unary(int256 x) external pure { // Cannot take unary of MIN_INT256, because its absolute value would be 1 unit larger than MAX_INT256. x = _bound(x, MIN_INT256 + 1, MAX_INT256); SD59x18 expected = sd(-x); @@ -135,7 +135,7 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { assertEq(-sd(x), expected, "SD59x18 -"); } - function testFuzz_UncheckedAdd(int256 x, int256 y) external { + function testFuzz_UncheckedAdd(int256 x, int256 y) external pure { unchecked { SD59x18 expected = sd(x + y); SD59x18 actual = uncheckedAdd(sd(x), sd(y)); @@ -143,7 +143,7 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { } } - function testFuzz_UncheckedSub(int256 x, int256 y) external { + function testFuzz_UncheckedSub(int256 x, int256 y) external pure { unchecked { SD59x18 expected = sd(x - y); SD59x18 actual = uncheckedSub(sd(x), sd(y)); @@ -151,7 +151,7 @@ contract SD59x18_Helpers_Fuzz_Test is Base_Test { } } - function testFuzz_Xor(int256 x, int256 y) external { + function testFuzz_Xor(int256 x, int256 y) external pure { SD59x18 expected = sd(x ^ y); assertEq(xor(sd(x), sd(y)), expected, "SD59x18 xor"); assertEq(sd(x) ^ sd(y), expected, "SD59x18 ^"); diff --git a/test/fuzz/sd59x18/math/pow/pow.t.sol b/test/fuzz/sd59x18/math/pow/pow.t.sol index 8a7096a1..ace977ce 100644 --- a/test/fuzz/sd59x18/math/pow/pow.t.sol +++ b/test/fuzz/sd59x18/math/pow/pow.t.sol @@ -8,7 +8,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { Base_Test } from "../../../../Base.t.sol"; contract Pow_Fuzz_Test is Base_Test { - function testFuzz_Pow_BaseZero_ExponentNotZero(SD59x18 y) external { + function testFuzz_Pow_BaseZero_ExponentNotZero(SD59x18 y) external pure { vm.assume(y != ZERO); SD59x18 x = ZERO; SD59x18 actual = pow(x, y); @@ -20,7 +20,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_BaseUnit(SD59x18 y) external whenBaseNotZero { + function testFuzz_Pow_BaseUnit(SD59x18 y) external pure whenBaseNotZero { SD59x18 x = UNIT; SD59x18 actual = pow(x, y); SD59x18 expected = UNIT; @@ -31,7 +31,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_ExponentZero(SD59x18 x) external whenBaseNotZero whenBaseNotUnit { + function testFuzz_Pow_ExponentZero(SD59x18 x) external pure whenBaseNotZero whenBaseNotUnit { vm.assume(x != ZERO && x != UNIT); SD59x18 y = ZERO; SD59x18 actual = pow(x, y); @@ -43,7 +43,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_ExponentUnit(SD59x18 x) external whenBaseNotZero whenBaseNotUnit whenExponentNotZero { + function testFuzz_Pow_ExponentUnit(SD59x18 x) external pure whenBaseNotZero whenBaseNotUnit whenExponentNotZero { vm.assume(x != ZERO && x != UNIT); SD59x18 y = UNIT; SD59x18 actual = pow(x, y); diff --git a/test/fuzz/ud2x18/casting/Casting.t.sol b/test/fuzz/ud2x18/casting/Casting.t.sol index dccd14cd..67f75930 100644 --- a/test/fuzz/ud2x18/casting/Casting.t.sol +++ b/test/fuzz/ud2x18/casting/Casting.t.sol @@ -20,32 +20,32 @@ contract UD2x18_Casting_Fuzz_Test is Base_Test { x.intoSD1x18(); } - function testFuzz_IntoSD1x18(UD2x18 x) external { + function testFuzz_IntoSD1x18(UD2x18 x) external pure { x = _bound(x, 0, uint64(uMAX_SD1x18)); SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(uint64(x.unwrap()))); assertEq(actual, expected, "UD2x18 intoSD1x18"); } - function testFuzz_IntoSD59x18(UD2x18 x) external { + function testFuzz_IntoSD59x18(UD2x18 x) external pure { SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(uint256(x.unwrap()))); assertEq(actual, expected, "UD2x18 intoSD59x18"); } - function testFuzz_IntoUD60x18(UD2x18 x) external { + function testFuzz_IntoUD60x18(UD2x18 x) external pure { UD60x18 actual = x.intoUD60x18(); UD60x18 expected = UD60x18.wrap(uint256(x.unwrap())); assertEq(actual, expected, "UD2x18 intoUD60x18"); } - function testFuzz_IntoUint128(UD2x18 x) external { + function testFuzz_IntoUint128(UD2x18 x) external pure { uint128 actual = x.intoUint128(); uint128 expected = uint128(x.unwrap()); assertEq(actual, expected, "UD2x18 intoUint128"); } - function testFuzz_IntoUint256(UD2x18 x) external { + function testFuzz_IntoUint256(UD2x18 x) external pure { uint256 actual = x.intoUint256(); uint256 expected = uint256(x.unwrap()); assertEq(actual, expected, "UD2x18 intoUint256"); @@ -57,26 +57,26 @@ contract UD2x18_Casting_Fuzz_Test is Base_Test { x.intoUint40(); } - function testFuzz_IntoUint40(UD2x18 x) external { + function testFuzz_IntoUint40(UD2x18 x) external pure { x = _bound(x, 0, uint64(MAX_UINT40)); uint40 actual = x.intoUint40(); uint40 expected = uint40(x.unwrap()); assertEq(actual, expected, "UD2x18 intoUint40"); } - function testFuzz_ud2x18(uint64 x) external { + function testFuzz_ud2x18(uint64 x) external pure { UD2x18 actual = ud2x18(x); UD2x18 expected = UD2x18.wrap(x); assertEq(actual, expected, "ud2x18"); } - function testFuzz_Unwrap(UD2x18 x) external { + function testFuzz_Unwrap(UD2x18 x) external pure { uint64 actual = x.unwrap(); uint64 expected = UD2x18.unwrap(x); assertEq(actual, expected, "UD2x18 unwrap"); } - function testFuzz_Wrap(uint64 x) external { + function testFuzz_Wrap(uint64 x) external pure { UD2x18 actual = wrap(x); UD2x18 expected = UD2x18.wrap(x); assertEq(actual, expected, "UD2x18 wrap"); diff --git a/test/fuzz/ud60x18/casting/Casting.t.sol b/test/fuzz/ud60x18/casting/Casting.t.sol index 20ade8a4..2b2d7513 100644 --- a/test/fuzz/ud60x18/casting/Casting.t.sol +++ b/test/fuzz/ud60x18/casting/Casting.t.sol @@ -28,7 +28,7 @@ contract UD60x18_Casting_Fuzz_Test is Base_Test { x.intoSD1x18(); } - function testFuzz_intoSD1x18(UD60x18 x) external { + function testFuzz_intoSD1x18(UD60x18 x) external pure { x = _bound(x, 0, ud(uint64(uMAX_SD1x18))); SD1x18 actual = x.intoSD1x18(); SD1x18 expected = SD1x18.wrap(int64(uint64(x.unwrap()))); @@ -41,7 +41,7 @@ contract UD60x18_Casting_Fuzz_Test is Base_Test { x.intoSD59x18(); } - function testFuzz_intoSD59x18(UD60x18 x) external { + function testFuzz_intoSD59x18(UD60x18 x) external pure { x = _bound(x, 0, ud(uint256(uMAX_SD59x18))); SD59x18 actual = x.intoSD59x18(); SD59x18 expected = SD59x18.wrap(int256(uint256(x.unwrap()))); @@ -54,7 +54,7 @@ contract UD60x18_Casting_Fuzz_Test is Base_Test { x.intoUD2x18(); } - function testFuzz_intoUD2x18(UD60x18 x) external { + function testFuzz_intoUD2x18(UD60x18 x) external pure { x = _bound(x, 0, ud(uint256(uMAX_UD2x18))); UD2x18 actual = x.intoUD2x18(); UD2x18 expected = UD2x18.wrap(uint64(x.unwrap())); @@ -67,14 +67,14 @@ contract UD60x18_Casting_Fuzz_Test is Base_Test { x.intoUint128(); } - function testFuzz_intoUint128(UD60x18 x) external { + function testFuzz_intoUint128(UD60x18 x) external pure { x = _bound(x, 0, ud(uint256(MAX_UINT128))); uint128 actual = x.intoUint128(); uint128 expected = uint128(x.unwrap()); assertEq(actual, expected, "UD60x18 intoUint128"); } - function testFuzz_intoUint256(UD60x18 x) external { + function testFuzz_intoUint256(UD60x18 x) external pure { uint256 actual = x.intoUint256(); uint256 expected = x.unwrap(); assertEq(actual, expected, "UD60x18 intoUint256"); @@ -86,32 +86,32 @@ contract UD60x18_Casting_Fuzz_Test is Base_Test { x.intoUint40(); } - function testFuzz_intoUint40(UD60x18 x) external { + function testFuzz_intoUint40(UD60x18 x) external pure { x = _bound(x, 0, ud(uint256(MAX_UINT40))); uint40 actual = uint40(x.intoUint40()); uint40 expected = uint40(x.unwrap()); assertEq(actual, expected, "UD60x18 intoUint40"); } - function testFuzz_Ud(uint256 x) external { + function testFuzz_Ud(uint256 x) external pure { UD60x18 actual = ud(x); UD60x18 expected = UD60x18.wrap(x); assertEq(actual, expected, "ud"); } - function testFuzz_UD60x18(uint256 x) external { + function testFuzz_UD60x18(uint256 x) external pure { UD60x18 actual = ud60x18(x); UD60x18 expected = UD60x18.wrap(x); assertEq(actual, expected, "ud60x18"); } - function testFuzz_Unwrap(UD60x18 x) external { + function testFuzz_Unwrap(UD60x18 x) external pure { uint256 actual = x.unwrap(); uint256 expected = UD60x18.unwrap(x); assertEq(actual, expected, "UD60x18 unwrap"); } - function testFuzz_Wrap(uint256 x) external { + function testFuzz_Wrap(uint256 x) external pure { UD60x18 actual = wrap(x); UD60x18 expected = UD60x18.wrap(x); assertEq(actual, expected, "UD60x18 wrap"); diff --git a/test/fuzz/ud60x18/helpers/Helpers.t.sol b/test/fuzz/ud60x18/helpers/Helpers.t.sol index 0138ed5d..c457bbba 100644 --- a/test/fuzz/ud60x18/helpers/Helpers.t.sol +++ b/test/fuzz/ud60x18/helpers/Helpers.t.sol @@ -30,7 +30,7 @@ import { Base_Test } from "../../../Base.t.sol"; contract UD60x18_Helpers_Fuzz_Test is Base_Test { uint256 internal constant HALF_MAX_UINT256 = type(uint256).max / 2; - function testFuzz_Add(UD60x18 x, UD60x18 y) external { + function testFuzz_Add(UD60x18 x, UD60x18 y) external pure { x = _bound(x, 0, HALF_MAX_UINT256); y = _bound(y, 0, HALF_MAX_UINT256); UD60x18 expected = ud(x.unwrap() + y.unwrap()); @@ -38,93 +38,93 @@ contract UD60x18_Helpers_Fuzz_Test is Base_Test { assertEq(x + y, expected, "UD60x18 +"); } - function testFuzz_And(uint256 x, uint256 y) external { + function testFuzz_And(uint256 x, uint256 y) external pure { UD60x18 expected = ud(x & y); assertEq(and(ud(x), y), expected, "UD60x18 and"); assertEq(ud(x) & ud(y), expected, "UD60x18 &"); } - function testFuzz_Eq(uint256 x) external { + function testFuzz_Eq(uint256 x) external pure { uint256 y = x; assertTrue(eq(ud(x), ud(y)), "UD60x18 eq"); assertTrue(ud(x) == ud(y), "UD60x18 =="); } - function testFuzz_Gt(uint256 x, uint256 y) external { + function testFuzz_Gt(uint256 x, uint256 y) external pure { vm.assume(x > y); assertTrue(gt(ud(x), ud(y)), "UD60x18 gt"); assertTrue(ud(x) > ud(y), "UD60x18 >"); } - function testFuzz_Gte(uint256 x, uint256 y) external { + function testFuzz_Gte(uint256 x, uint256 y) external pure { vm.assume(x >= y); assertTrue(gte(ud(x), ud(y)), "UD60x18 gte"); assertTrue(ud(x) >= ud(y), "UD60x18 >="); } - function testFuzz_IsZero(UD60x18 x) external { + function testFuzz_IsZero(UD60x18 x) external pure { bool actual = isZero(x); bool expected = x == ud(0); assertEq(actual, expected, "SD59x18 isZero"); } - function testFuzz_Lshift(uint256 x, uint256 y) external { + function testFuzz_Lshift(uint256 x, uint256 y) external pure { vm.assume(y <= 512); UD60x18 expected = ud(x << y); assertEq(lshift(ud(x), y), expected, "UD60x18 lshift"); } - function testFuzz_Lt(uint256 x, uint256 y) external { + function testFuzz_Lt(uint256 x, uint256 y) external pure { vm.assume(x < y); assertTrue(lt(ud(x), ud(y)), "UD60x18 lt"); assertTrue(ud(x) < ud(y), "UD60x18 <"); } - function testFuzz_Lte(uint256 x, uint256 y) external { + function testFuzz_Lte(uint256 x, uint256 y) external pure { vm.assume(x <= y); assertTrue(lte(ud(x), ud(y)), "UD60x18 lte"); assertTrue(ud(x) <= ud(y), "UD60x18 <="); } - function testFuzz_Mod(uint256 x, uint256 y) external { + function testFuzz_Mod(uint256 x, uint256 y) external pure { vm.assume(y > 0); UD60x18 expected = ud(x % y); assertEq(mod(ud(x), ud(y)), expected, "UD60x18 mod"); assertEq(ud(x) % ud(y), expected, "UD60x18 %"); } - function testFuzz_Neq(uint256 x, uint256 y) external { + function testFuzz_Neq(uint256 x, uint256 y) external pure { vm.assume(x != y); assertTrue(neq(ud(x), ud(y)), "UD60x18 neq"); assertTrue(ud(x) != ud(y), "UD60x18 !="); } - function testFuzz_Not(uint256 x) external { + function testFuzz_Not(uint256 x) external pure { UD60x18 expected = ud(~x); assertEq(not(ud(x)), expected, "UD60x18 not"); assertEq(~ud(x), expected, "UD60x18 ~"); } - function testFuzz_Or(uint256 x, uint256 y) external { + function testFuzz_Or(uint256 x, uint256 y) external pure { UD60x18 expected = ud(x | y); assertEq(or(ud(x), ud(y)), expected, "UD60x18 or"); assertEq(ud(x) | ud(y), expected, "UD60x18 |"); } - function testFuzz_Rshift(uint256 x, uint256 y) external { + function testFuzz_Rshift(uint256 x, uint256 y) external pure { vm.assume(y <= 512); UD60x18 expected = ud(x >> y); assertEq(rshift(ud(x), y), expected, "UD60x18 rshift"); } - function testFuzz_Sub(uint256 x, uint256 y) external { + function testFuzz_Sub(uint256 x, uint256 y) external pure { vm.assume(x >= y); UD60x18 expected = ud(x - y); assertEq(sub(ud(x), ud(y)), expected, "UD60x18 sub"); assertEq(ud(x) - ud(y), expected, "UD60x18 -"); } - function testFuzz_UncheckedAdd(uint256 x, uint256 y) external { + function testFuzz_UncheckedAdd(uint256 x, uint256 y) external pure { unchecked { UD60x18 expected = ud(x + y); UD60x18 actual = uncheckedAdd(ud(x), ud(y)); @@ -132,7 +132,7 @@ contract UD60x18_Helpers_Fuzz_Test is Base_Test { } } - function testFuzz_UncheckedSub(uint256 x, uint256 y) external { + function testFuzz_UncheckedSub(uint256 x, uint256 y) external pure { unchecked { UD60x18 expected = ud(x - y); UD60x18 actual = uncheckedSub(ud(x), ud(y)); @@ -140,7 +140,7 @@ contract UD60x18_Helpers_Fuzz_Test is Base_Test { } } - function testFuzz_Xor(uint256 x, uint256 y) external { + function testFuzz_Xor(uint256 x, uint256 y) external pure { UD60x18 expected = ud(x ^ y); assertEq(xor(ud(x), ud(y)), expected, "UD60x18 xor"); assertEq(ud(x) ^ ud(y), expected, "UD60x18 ^"); diff --git a/test/fuzz/ud60x18/math/pow/pow.t.sol b/test/fuzz/ud60x18/math/pow/pow.t.sol index 6fcc2273..52d2d879 100644 --- a/test/fuzz/ud60x18/math/pow/pow.t.sol +++ b/test/fuzz/ud60x18/math/pow/pow.t.sol @@ -8,7 +8,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { Base_Test } from "../../../../Base.t.sol"; contract Pow_Fuzz_Test is Base_Test { - function testFuzz_Pow_BaseZero_ExponentNotZero(UD60x18 y) external { + function testFuzz_Pow_BaseZero_ExponentNotZero(UD60x18 y) external pure { vm.assume(y != ZERO); UD60x18 x = ZERO; UD60x18 actual = pow(x, y); @@ -20,7 +20,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_BaseUnit(UD60x18 y) external whenBaseNotZero { + function testFuzz_Pow_BaseUnit(UD60x18 y) external pure whenBaseNotZero { UD60x18 x = UNIT; UD60x18 actual = pow(x, y); UD60x18 expected = UNIT; @@ -31,7 +31,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_ExponentZero(UD60x18 x) external whenBaseNotZero whenBaseNotUnit { + function testFuzz_Pow_ExponentZero(UD60x18 x) external pure whenBaseNotZero whenBaseNotUnit { vm.assume(x != ZERO && x != UNIT); UD60x18 y = ZERO; UD60x18 actual = pow(x, y); @@ -43,7 +43,7 @@ contract Pow_Fuzz_Test is Base_Test { _; } - function testFuzz_Pow_ExponentUnit(UD60x18 x) external whenBaseNotZero whenBaseNotUnit whenExponentNotZero { + function testFuzz_Pow_ExponentUnit(UD60x18 x) external pure whenBaseNotZero whenBaseNotUnit whenExponentNotZero { vm.assume(x != ZERO && x != UNIT); UD60x18 y = UNIT; UD60x18 actual = pow(x, y); diff --git a/test/unit/sd59x18/math/abs/abs.t.sol b/test/unit/sd59x18/math/abs/abs.t.sol index 3ca2b6fe..3bbf9f50 100644 --- a/test/unit/sd59x18/math/abs/abs.t.sol +++ b/test/unit/sd59x18/math/abs/abs.t.sol @@ -10,7 +10,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Abs_Unit_Test is SD59x18_Unit_Test { - function test_Abs_Zero() external { + function test_Abs_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = abs(x); SD59x18 expected = ZERO; diff --git a/test/unit/sd59x18/math/avg/avg.t.sol b/test/unit/sd59x18/math/avg/avg.t.sol index 6f6ce3a6..ae98ca3d 100644 --- a/test/unit/sd59x18/math/avg/avg.t.sol +++ b/test/unit/sd59x18/math/avg/avg.t.sol @@ -8,7 +8,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Avg_Unit_Test is SD59x18_Unit_Test { - function test_Avg_BothOperandsZero() external { + function test_Avg_BothOperandsZero() external pure { SD59x18 x = ZERO; SD59x18 y = ZERO; SD59x18 actual = avg(x, y); diff --git a/test/unit/sd59x18/math/ceil/ceil.t.sol b/test/unit/sd59x18/math/ceil/ceil.t.sol index c02981ad..d40e4721 100644 --- a/test/unit/sd59x18/math/ceil/ceil.t.sol +++ b/test/unit/sd59x18/math/ceil/ceil.t.sol @@ -10,7 +10,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Ceil_Unit_Test is SD59x18_Unit_Test { - function test_Ceil_Zero() external { + function test_Ceil_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = ceil(x); SD59x18 expected = ZERO; diff --git a/test/unit/sd59x18/math/exp/exp.t.sol b/test/unit/sd59x18/math/exp/exp.t.sol index 288588a9..401c9b6d 100644 --- a/test/unit/sd59x18/math/exp/exp.t.sol +++ b/test/unit/sd59x18/math/exp/exp.t.sol @@ -12,7 +12,7 @@ import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Exp_Unit_Test is SD59x18_Unit_Test { SD59x18 internal constant THRESHOLD = SD59x18.wrap(-41_446531673892822322); - function test_Exp_Zero() external { + function test_Exp_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = exp(x); SD59x18 expected = UNIT; diff --git a/test/unit/sd59x18/math/exp2/exp2.t.sol b/test/unit/sd59x18/math/exp2/exp2.t.sol index 54902e72..a79450c0 100644 --- a/test/unit/sd59x18/math/exp2/exp2.t.sol +++ b/test/unit/sd59x18/math/exp2/exp2.t.sol @@ -13,7 +13,7 @@ contract Exp2_Unit_Test is SD59x18_Unit_Test { /// @dev Any input smaller than this makes the result zero. SD59x18 internal constant THRESHOLD = SD59x18.wrap(-59_794705707972522261); - function test_Exp2_Zero() external { + function test_Exp2_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = exp2(x); SD59x18 expected = UNIT; diff --git a/test/unit/sd59x18/math/floor/floor.t.sol b/test/unit/sd59x18/math/floor/floor.t.sol index 2555078b..14c420eb 100644 --- a/test/unit/sd59x18/math/floor/floor.t.sol +++ b/test/unit/sd59x18/math/floor/floor.t.sol @@ -10,7 +10,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Floor_Unit_Test is SD59x18_Unit_Test { - function test_Floor_Zero() external { + function test_Floor_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = floor(x); SD59x18 expected = ZERO; diff --git a/test/unit/sd59x18/math/frac/frac.t.sol b/test/unit/sd59x18/math/frac/frac.t.sol index 3599a311..e8076dee 100644 --- a/test/unit/sd59x18/math/frac/frac.t.sol +++ b/test/unit/sd59x18/math/frac/frac.t.sol @@ -8,7 +8,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Frac_Unit_Test is SD59x18_Unit_Test { - function test_Frac_Zero() external { + function test_Frac_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = frac(x); SD59x18 expected = ZERO; diff --git a/test/unit/sd59x18/math/pow/pow.t.sol b/test/unit/sd59x18/math/pow/pow.t.sol index 6c1be041..eed93d9c 100644 --- a/test/unit/sd59x18/math/pow/pow.t.sol +++ b/test/unit/sd59x18/math/pow/pow.t.sol @@ -8,7 +8,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Pow_Unit_Test is SD59x18_Unit_Test { - function test_Pow_BaseZero_ExponentZero() external { + function test_Pow_BaseZero_ExponentZero() external pure { SD59x18 x = ZERO; SD59x18 y = ZERO; SD59x18 actual = pow(x, y); @@ -16,7 +16,7 @@ contract Pow_Unit_Test is SD59x18_Unit_Test { assertEq(actual, expected, "SD59x18 pow"); } - function test_Pow_BaseZero_ExponentNotZero() external { + function test_Pow_BaseZero_ExponentNotZero() external pure { SD59x18 x = ZERO; SD59x18 y = UNIT; SD59x18 actual = pow(x, y); @@ -28,7 +28,7 @@ contract Pow_Unit_Test is SD59x18_Unit_Test { _; } - function test_Pow_BaseUnit() external whenBaseNotZero { + function test_Pow_BaseUnit() external pure whenBaseNotZero { SD59x18 x = UNIT; SD59x18 y = PI; SD59x18 actual = pow(x, y); @@ -40,7 +40,7 @@ contract Pow_Unit_Test is SD59x18_Unit_Test { _; } - function test_Pow_ExponentZero() external whenBaseNotZero whenBaseNotUnit { + function test_Pow_ExponentZero() external pure whenBaseNotZero whenBaseNotUnit { SD59x18 x = PI; SD59x18 y = ZERO; SD59x18 actual = pow(x, y); @@ -52,7 +52,7 @@ contract Pow_Unit_Test is SD59x18_Unit_Test { _; } - function test_Pow_ExponentUnit() external whenBaseNotZero whenBaseNotUnit whenExponentNotZero { + function test_Pow_ExponentUnit() external pure whenBaseNotZero whenBaseNotUnit whenExponentNotZero { SD59x18 x = PI; SD59x18 y = UNIT; SD59x18 actual = pow(x, y); diff --git a/test/unit/sd59x18/math/powu/powu.t.sol b/test/unit/sd59x18/math/powu/powu.t.sol index 46caaede..468491bd 100644 --- a/test/unit/sd59x18/math/powu/powu.t.sol +++ b/test/unit/sd59x18/math/powu/powu.t.sol @@ -13,7 +13,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Powu_Unit_Test is SD59x18_Unit_Test { - function test_Powu_BaseAndExponentZero() external { + function test_Powu_BaseAndExponentZero() external pure { SD59x18 x = ZERO; uint256 y = 0; SD59x18 actual = powu(x, y); diff --git a/test/unit/sd59x18/math/sqrt/sqrt.t.sol b/test/unit/sd59x18/math/sqrt/sqrt.t.sol index 37c8fb47..ffbafeba 100644 --- a/test/unit/sd59x18/math/sqrt/sqrt.t.sol +++ b/test/unit/sd59x18/math/sqrt/sqrt.t.sol @@ -10,7 +10,7 @@ import { SD59x18 } from "src/sd59x18/ValueType.sol"; import { SD59x18_Unit_Test } from "../../SD59x18.t.sol"; contract Sqrt_Unit_Test is SD59x18_Unit_Test { - function test_Sqrt_Zero() external { + function test_Sqrt_Zero() external pure { SD59x18 x = ZERO; SD59x18 actual = sqrt(x); SD59x18 expected = ZERO; diff --git a/test/unit/ud60x18/UD60x18.t.sol b/test/unit/ud60x18/UD60x18.t.sol index ede9bfb2..e949c7b3 100644 --- a/test/unit/ud60x18/UD60x18.t.sol +++ b/test/unit/ud60x18/UD60x18.t.sol @@ -57,14 +57,14 @@ abstract contract UD60x18_Unit_Test is Base_Test { CONSTANT HELPER FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ - function log(string memory p0, UD60x18 p1) internal pure { - console2.log(p0, p1.unwrap()); - } - function logUd(UD60x18 p0) internal pure { console2.logUint(p0.unwrap()); } + function logUd(string memory p0, UD60x18 p1) internal pure { + console2.log(p0, p1.unwrap()); + } + function set(uint256 x) internal pure returns (Set memory) { return Set({ x: ud(x), y: ZERO, expected: ZERO }); } diff --git a/test/unit/ud60x18/math/avg/avg.t.sol b/test/unit/ud60x18/math/avg/avg.t.sol index 22e249e1..8a9621d7 100644 --- a/test/unit/ud60x18/math/avg/avg.t.sol +++ b/test/unit/ud60x18/math/avg/avg.t.sol @@ -8,7 +8,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Avg_Unit_Test is UD60x18_Unit_Test { - function test_Avg_BothOperandsZero() external { + function test_Avg_BothOperandsZero() external pure { UD60x18 x = ZERO; UD60x18 y = ZERO; UD60x18 actual = avg(x, y); diff --git a/test/unit/ud60x18/math/ceil/ceil.t.sol b/test/unit/ud60x18/math/ceil/ceil.t.sol index 6a0ca5a7..ead50241 100644 --- a/test/unit/ud60x18/math/ceil/ceil.t.sol +++ b/test/unit/ud60x18/math/ceil/ceil.t.sol @@ -10,7 +10,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract CeilTest is UD60x18_Unit_Test { - function test_Ceil_Zero() external { + function test_Ceil_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = ceil(x); UD60x18 expected = ZERO; diff --git a/test/unit/ud60x18/math/exp/exp.t.sol b/test/unit/ud60x18/math/exp/exp.t.sol index be13ebc1..29560d2b 100644 --- a/test/unit/ud60x18/math/exp/exp.t.sol +++ b/test/unit/ud60x18/math/exp/exp.t.sol @@ -10,7 +10,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Exp_Unit_Test is UD60x18_Unit_Test { - function test_Exp_Zero() external { + function test_Exp_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = exp(x); UD60x18 expected = UNIT; diff --git a/test/unit/ud60x18/math/exp2/exp2.t.sol b/test/unit/ud60x18/math/exp2/exp2.t.sol index 3d5a92e2..1c57dc8d 100644 --- a/test/unit/ud60x18/math/exp2/exp2.t.sol +++ b/test/unit/ud60x18/math/exp2/exp2.t.sol @@ -12,7 +12,7 @@ import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Exp2_Unit_Test is UD60x18_Unit_Test { UD60x18 internal constant MAX_PERMITTED = UD60x18.wrap(192e18 - 1); - function test_Exp2_Zero() external { + function test_Exp2_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = exp2(x); UD60x18 expected = UNIT; diff --git a/test/unit/ud60x18/math/floor/floor.t.sol b/test/unit/ud60x18/math/floor/floor.t.sol index 0869596b..4f2ba3fb 100644 --- a/test/unit/ud60x18/math/floor/floor.t.sol +++ b/test/unit/ud60x18/math/floor/floor.t.sol @@ -8,7 +8,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Floor_Unit_Test is UD60x18_Unit_Test { - function test_Floor_Zero() external { + function test_Floor_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = floor(x); UD60x18 expected = ZERO; diff --git a/test/unit/ud60x18/math/frac/frac.t.sol b/test/unit/ud60x18/math/frac/frac.t.sol index e4d8176f..e571d664 100644 --- a/test/unit/ud60x18/math/frac/frac.t.sol +++ b/test/unit/ud60x18/math/frac/frac.t.sol @@ -8,7 +8,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Frac_Unit_Test is UD60x18_Unit_Test { - function test_Frac_Zero() external { + function test_Frac_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = frac(x); UD60x18 expected = ZERO; diff --git a/test/unit/ud60x18/math/pow/pow.t.sol b/test/unit/ud60x18/math/pow/pow.t.sol index 46937a8f..8e46ee02 100644 --- a/test/unit/ud60x18/math/pow/pow.t.sol +++ b/test/unit/ud60x18/math/pow/pow.t.sol @@ -8,7 +8,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Pow_Unit_Test is UD60x18_Unit_Test { - function test_Pow_BaseZero_ExponentZero() external { + function test_Pow_BaseZero_ExponentZero() external pure { UD60x18 x = ZERO; UD60x18 y = ZERO; UD60x18 actual = pow(x, y); @@ -16,7 +16,7 @@ contract Pow_Unit_Test is UD60x18_Unit_Test { assertEq(actual, expected, "UD60x18 pow"); } - function test_Pow_BaseZero_ExponentNotZero() external { + function test_Pow_BaseZero_ExponentNotZero() external pure { UD60x18 x = ZERO; UD60x18 y = PI; UD60x18 actual = pow(x, y); @@ -28,7 +28,7 @@ contract Pow_Unit_Test is UD60x18_Unit_Test { _; } - function test_Pow_BaseUnit() external whenBaseNotZero { + function test_Pow_BaseUnit() external pure whenBaseNotZero { UD60x18 x = UNIT; UD60x18 y = PI; UD60x18 actual = pow(x, y); @@ -40,7 +40,7 @@ contract Pow_Unit_Test is UD60x18_Unit_Test { _; } - function test_Pow_ExponentZero() external whenBaseNotZero whenBaseNotUnit { + function test_Pow_ExponentZero() external pure whenBaseNotZero whenBaseNotUnit { UD60x18 x = PI; UD60x18 y = ZERO; UD60x18 actual = pow(x, y); @@ -52,7 +52,7 @@ contract Pow_Unit_Test is UD60x18_Unit_Test { _; } - function test_Pow_ExponentUnit(UD60x18 x) external whenBaseNotZero whenBaseNotUnit whenExponentNotZero { + function test_Pow_ExponentUnit(UD60x18 x) external pure whenBaseNotZero whenBaseNotUnit whenExponentNotZero { vm.assume(x != ZERO && x != UNIT); UD60x18 y = UNIT; UD60x18 actual = pow(x, y); diff --git a/test/unit/ud60x18/math/powu/powu.t.sol b/test/unit/ud60x18/math/powu/powu.t.sol index 84cf1296..f305e3dd 100644 --- a/test/unit/ud60x18/math/powu/powu.t.sol +++ b/test/unit/ud60x18/math/powu/powu.t.sol @@ -10,7 +10,7 @@ import { UD60x18 } from "src/ud60x18/ValueType.sol"; import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Powu_Unit_Test is UD60x18_Unit_Test { - function test_Powu_BaseAndExponentZero() external { + function test_Powu_BaseAndExponentZero() external pure { UD60x18 x = ZERO; uint256 y = 0; UD60x18 actual = powu(x, y); diff --git a/test/unit/ud60x18/math/sqrt/sqrt.t.sol b/test/unit/ud60x18/math/sqrt/sqrt.t.sol index ce724bde..5ca654bb 100644 --- a/test/unit/ud60x18/math/sqrt/sqrt.t.sol +++ b/test/unit/ud60x18/math/sqrt/sqrt.t.sol @@ -11,7 +11,7 @@ import { UD60x18_Unit_Test } from "../../UD60x18.t.sol"; contract Sqrt_Unit_Test is UD60x18_Unit_Test { UD60x18 internal constant MAX_PERMITTED = UD60x18.wrap(115792089237316195423570985008687907853269_984665640564039457); - function test_Sqrt_Zero() external { + function test_Sqrt_Zero() external pure { UD60x18 x = ZERO; UD60x18 actual = sqrt(x); UD60x18 expected = ZERO; diff --git a/test/utils/Assertions.sol b/test/utils/Assertions.sol index 90e6354b..6ff7c660 100644 --- a/test/utils/Assertions.sol +++ b/test/utils/Assertions.sol @@ -1,43 +1,43 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.19; -import { PRBTest } from "@prb/test/src/PRBTest.sol"; +import { StdAssertions } from "forge-std/src/StdAssertions.sol"; import { SD1x18 } from "../../src/sd1x18/ValueType.sol"; import { SD59x18 } from "../../src/sd59x18/ValueType.sol"; import { UD2x18 } from "../../src/ud2x18/ValueType.sol"; import { UD60x18 } from "../../src/ud60x18/ValueType.sol"; -contract PRBMathAssertions is PRBTest { +contract PRBMathAssertions is StdAssertions { /*////////////////////////////////////////////////////////////////////////// SD1X18 //////////////////////////////////////////////////////////////////////////*/ - function assertEq(SD1x18 a, SD1x18 b) internal { + function assertEq(SD1x18 a, SD1x18 b) internal pure { assertEq(SD1x18.unwrap(a), SD1x18.unwrap(b)); } - function assertEq(SD1x18 a, SD1x18 b, string memory err) internal { + function assertEq(SD1x18 a, SD1x18 b, string memory err) internal pure { assertEq(SD1x18.unwrap(a), SD1x18.unwrap(b), err); } - function assertEq(SD1x18 a, int64 b) internal { + function assertEq(SD1x18 a, int64 b) internal pure { assertEq(SD1x18.unwrap(a), b); } - function assertEq(SD1x18 a, int64 b, string memory err) internal { + function assertEq(SD1x18 a, int64 b, string memory err) internal pure { assertEq(SD1x18.unwrap(a), b, err); } - function assertEq(int64 a, SD1x18 b) internal { + function assertEq(int64 a, SD1x18 b) internal pure { assertEq(a, SD1x18.unwrap(b)); } - function assertEq(int64 a, SD1x18 b, string memory err) internal { + function assertEq(int64 a, SD1x18 b, string memory err) internal pure { assertEq(a, SD1x18.unwrap(b), err); } - function assertEq(SD1x18[] memory a, SD1x18[] memory b) internal { + function assertEq(SD1x18[] memory a, SD1x18[] memory b) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -47,7 +47,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(SD1x18[] memory a, SD1x18[] memory b, string memory err) internal { + function assertEq(SD1x18[] memory a, SD1x18[] memory b, string memory err) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -57,7 +57,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(SD1x18[] memory a, int64[] memory b) internal { + function assertEq(SD1x18[] memory a, int64[] memory b) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -67,7 +67,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(SD1x18[] memory a, int64[] memory b, string memory err) internal { + function assertEq(SD1x18[] memory a, int64[] memory b, string memory err) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -77,7 +77,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(int64[] memory a, SD1x18[] memory b) internal { + function assertEq(int64[] memory a, SD1x18[] memory b) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -87,7 +87,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(int64[] memory a, SD1x18[] memory b, string memory err) internal { + function assertEq(int64[] memory a, SD1x18[] memory b, string memory err) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -101,31 +101,31 @@ contract PRBMathAssertions is PRBTest { SD59X18 //////////////////////////////////////////////////////////////////////////*/ - function assertEq(SD59x18 a, SD59x18 b) internal { + function assertEq(SD59x18 a, SD59x18 b) internal pure { assertEq(SD59x18.unwrap(a), SD59x18.unwrap(b)); } - function assertEq(SD59x18 a, SD59x18 b, string memory err) internal { + function assertEq(SD59x18 a, SD59x18 b, string memory err) internal pure { assertEq(SD59x18.unwrap(a), SD59x18.unwrap(b), err); } - function assertEq(SD59x18 a, int256 b) internal { + function assertEq(SD59x18 a, int256 b) internal pure { assertEq(SD59x18.unwrap(a), b); } - function assertEq(SD59x18 a, int256 b, string memory err) internal { + function assertEq(SD59x18 a, int256 b, string memory err) internal pure { assertEq(SD59x18.unwrap(a), b, err); } - function assertEq(int256 a, SD59x18 b) internal { + function assertEq(int256 a, SD59x18 b) internal pure { assertEq(a, SD59x18.unwrap(b)); } - function assertEq(int256 a, SD59x18 b, string memory err) internal { + function assertEq(int256 a, SD59x18 b, string memory err) internal pure { assertEq(a, SD59x18.unwrap(b), err); } - function assertEq(SD59x18[] memory a, SD59x18[] memory b) internal { + function assertEq(SD59x18[] memory a, SD59x18[] memory b) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -135,7 +135,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(SD59x18[] memory a, SD59x18[] memory b, string memory err) internal { + function assertEq(SD59x18[] memory a, SD59x18[] memory b, string memory err) internal pure { int256[] memory castedA; int256[] memory castedB; assembly { @@ -145,7 +145,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(SD59x18[] memory a, int256[] memory b) internal { + function assertEq(SD59x18[] memory a, int256[] memory b) internal pure { int256[] memory castedA; assembly { castedA := a @@ -153,7 +153,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, b); } - function assertEq(SD59x18[] memory a, int256[] memory b, string memory err) internal { + function assertEq(SD59x18[] memory a, int256[] memory b, string memory err) internal pure { int256[] memory castedA; assembly { castedA := a @@ -181,31 +181,31 @@ contract PRBMathAssertions is PRBTest { UD2X18 //////////////////////////////////////////////////////////////////////////*/ - function assertEq(UD2x18 a, UD2x18 b) internal { + function assertEq(UD2x18 a, UD2x18 b) internal pure { assertEq(UD2x18.unwrap(a), UD2x18.unwrap(b)); } - function assertEq(UD2x18 a, UD2x18 b, string memory err) internal { + function assertEq(UD2x18 a, UD2x18 b, string memory err) internal pure { assertEq(UD2x18.unwrap(a), UD2x18.unwrap(b), err); } - function assertEq(UD2x18 a, uint64 b) internal { + function assertEq(UD2x18 a, uint64 b) internal pure { assertEq(UD2x18.unwrap(a), uint256(b)); } - function assertEq(UD2x18 a, uint64 b, string memory err) internal { + function assertEq(UD2x18 a, uint64 b, string memory err) internal pure { assertEq(UD2x18.unwrap(a), uint256(b), err); } - function assertEq(uint64 a, UD2x18 b) internal { + function assertEq(uint64 a, UD2x18 b) internal pure { assertEq(uint256(a), UD2x18.unwrap(b)); } - function assertEq(uint64 a, UD2x18 b, string memory err) internal { + function assertEq(uint64 a, UD2x18 b, string memory err) internal pure { assertEq(uint256(a), UD2x18.unwrap(b), err); } - function assertEq(UD2x18[] memory a, UD2x18[] memory b) internal { + function assertEq(UD2x18[] memory a, UD2x18[] memory b) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -215,7 +215,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(UD2x18[] memory a, UD2x18[] memory b, string memory err) internal { + function assertEq(UD2x18[] memory a, UD2x18[] memory b, string memory err) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -225,7 +225,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(UD2x18[] memory a, uint64[] memory b) internal { + function assertEq(UD2x18[] memory a, uint64[] memory b) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -235,7 +235,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(UD2x18[] memory a, uint64[] memory b, string memory err) internal { + function assertEq(UD2x18[] memory a, uint64[] memory b, string memory err) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -245,7 +245,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(uint64[] memory a, UD2x18[] memory b) internal { + function assertEq(uint64[] memory a, UD2x18[] memory b) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -255,7 +255,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(uint64[] memory a, UD2x18[] memory b, string memory err) internal { + function assertEq(uint64[] memory a, UD2x18[] memory b, string memory err) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -269,31 +269,31 @@ contract PRBMathAssertions is PRBTest { UD60X18 //////////////////////////////////////////////////////////////////////////*/ - function assertEq(UD60x18 a, UD60x18 b) internal { + function assertEq(UD60x18 a, UD60x18 b) internal pure { assertEq(UD60x18.unwrap(a), UD60x18.unwrap(b)); } - function assertEq(UD60x18 a, UD60x18 b, string memory err) internal { + function assertEq(UD60x18 a, UD60x18 b, string memory err) internal pure { assertEq(UD60x18.unwrap(a), UD60x18.unwrap(b), err); } - function assertEq(UD60x18 a, uint256 b) internal { + function assertEq(UD60x18 a, uint256 b) internal pure { assertEq(UD60x18.unwrap(a), b); } - function assertEq(UD60x18 a, uint256 b, string memory err) internal { + function assertEq(UD60x18 a, uint256 b, string memory err) internal pure { assertEq(UD60x18.unwrap(a), b, err); } - function assertEq(uint256 a, UD60x18 b) internal { + function assertEq(uint256 a, UD60x18 b) internal pure { assertEq(a, UD60x18.unwrap(b)); } - function assertEq(uint256 a, UD60x18 b, string memory err) internal { + function assertEq(uint256 a, UD60x18 b, string memory err) internal pure { assertEq(a, UD60x18.unwrap(b), err); } - function assertEq(UD60x18[] memory a, UD60x18[] memory b) internal { + function assertEq(UD60x18[] memory a, UD60x18[] memory b) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -303,7 +303,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB); } - function assertEq(UD60x18[] memory a, UD60x18[] memory b, string memory err) internal { + function assertEq(UD60x18[] memory a, UD60x18[] memory b, string memory err) internal pure { uint256[] memory castedA; uint256[] memory castedB; assembly { @@ -313,7 +313,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, castedB, err); } - function assertEq(UD60x18[] memory a, uint256[] memory b) internal { + function assertEq(UD60x18[] memory a, uint256[] memory b) internal pure { uint256[] memory castedA; assembly { castedA := a @@ -321,7 +321,7 @@ contract PRBMathAssertions is PRBTest { assertEq(castedA, b); } - function assertEq(UD60x18[] memory a, uint256[] memory b, string memory err) internal { + function assertEq(UD60x18[] memory a, uint256[] memory b, string memory err) internal pure { uint256[] memory castedA; assembly { castedA := a