From c951296c74245d9f466afca1b02024e60040f4e4 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Mon, 2 Oct 2023 06:26:51 +0530 Subject: [PATCH] fixed errors --- src/WRAPPER.huff | 24 +++++++------- test/Complex.t.sol | 74 ++++++++++++++++++++++++++++++++++++++++++ test/SimpleStore.t.sol | 29 ----------------- 3 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 test/Complex.t.sol delete mode 100644 test/SimpleStore.t.sol diff --git a/src/WRAPPER.huff b/src/WRAPPER.huff index 6e88d2d..a575509 100644 --- a/src/WRAPPER.huff +++ b/src/WRAPPER.huff @@ -1,18 +1,18 @@ #include './Complex.huff' -#define function addZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) -#define function subZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) -#define function mulZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) -#define function divZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) -#define function calcR(int256 , int 256, int256 , int256) returns (int256 ,int256) -#define function toPolar(int256 , int 256) returns (int256 ,int256) -#define function fromPolar(int256 , int 256) returns (int256 ,int256) -#define function p_atan2(int256 , int 256) returns (int256) +#define function addZ(int256 , int256 , int256 , int256) returns (int256 ,int256) +#define function subZ(int256 , int256 , int256 , int256) returns (int256 ,int256) +#define function mulZ(int256 , int256 , int256 , int256) returns (int256 ,int256) +#define function divZ(int256 , int256 , int256 , int256) returns (int256 ,int256) +#define function calcR(int256 , int256, int256 , int256) returns (int256 ,int256) +#define function toPolar(int256 , int256) returns (int256 ,int256) +#define function fromPolar(int256 , int256) returns (int256 ,int256) +#define function p_atan2(int256 , int256) returns (int256) #define function atan1to1(int256 ) returns (int256) -#define function ln(int256 , int 256) returns (int256) -#define function sqrt(int256 , int 256) returns (int256) -#define function expZ(int256 , int 256) returns (int256 ,int256) -#define function pow(int256 , int 256 , int256) returns (int256 ,int256) +#define function ln(int256 , int256) returns (int256) +#define function sqrt(int256 , int256) returns (int256) +#define function expZ(int256 , int256) returns (int256 ,int256) +#define function pow(int256 , int256 , int256) returns (int256 ,int256) #define macro MAIN() = takes (0) returns (0) { diff --git a/test/Complex.t.sol b/test/Complex.t.sol new file mode 100644 index 0000000..50ddf84 --- /dev/null +++ b/test/Complex.t.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity ^0.8.15; + +import "foundry-huff/HuffDeployer.sol"; +import "forge-std/Test.sol"; +import "forge-std/console.sol"; + +contract ComplexTest is Test { + Complex public complex; + + function setUp() public { + address com = HuffDeployer.deploy("Wrapper"); + complex = Complex(com); + } + + function testAddZ() public { + (int256 r, int256 i) = complex.addZ(1, 2, 3, 4); + assertEq(r, 3); + assertEq(i, 7); + } +} + +interface Complex { + function addZ( + int256, + int256, + int256, + int256 + ) external returns (int256, int256); + + function subZ( + int256, + int256, + int256, + int256 + ) external returns (int256, int256); + + function mulZ( + int256, + int256, + int256, + int256 + ) external returns (int256, int256); + + function divZ( + int256, + int256, + int256, + int256 + ) external returns (int256, int256); + + function calcR( + int256, + int256, + int256, + int256 + ) external returns (int256, int256); + + function toPolar(int256, int256) external returns (int256, int256); + + function fromPolar(int256, int256) external returns (int256, int256); + + function p_atan2(int256, int256) external returns (int256); + + function atan1to1(int256) external returns (int256); + + function ln(int256, int256) external returns (int256); + + function sqrt(int256, int256) external returns (int256); + + function expZ(int256, int256) external returns (int256, int256); + + function pow(int256, int256, int256) external returns (int256, int256); +} diff --git a/test/SimpleStore.t.sol b/test/SimpleStore.t.sol deleted file mode 100644 index 003763c..0000000 --- a/test/SimpleStore.t.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.15; - -import "foundry-huff/HuffDeployer.sol"; -import "forge-std/Test.sol"; -import "forge-std/console.sol"; - -contract SimpleStoreTest is Test { - /// @dev Address of the SimpleStore contract. - SimpleStore public simpleStore; - - /// @dev Setup the testing environment. - function setUp() public { - simpleStore = SimpleStore(HuffDeployer.deploy("SimpleStore")); - } - - /// @dev Ensure that you can set and get the value. - function testSetAndGetValue(uint256 value) public { - simpleStore.setValue(value); - console.log(value); - console.log(simpleStore.getValue()); - assertEq(value, simpleStore.getValue()); - } -} - -interface SimpleStore { - function setValue(uint256) external; - function getValue() external returns (uint256); -}