This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from huff-language/@abigger87/update_test_actions
fixes
- Loading branch information
Showing
6 changed files
with
121 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: ci | ||
|
||
on: [push] | ||
|
||
jobs: | ||
name: Tests in Huff | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
- name: Install Huff | ||
uses: huff-language/huff-toolchain@v2 | ||
with: | ||
version: nightly | ||
- name: Huff Tests | ||
uses: huff-language/[email protected] | ||
with: | ||
with-location: "tests" # defaults to "src" | ||
with-extension: "*.t.huff" # default | ||
with-format: "table" # default, either ["list", "table", "json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[profile.default] | ||
out = 'out' | ||
libs = ['lib'] | ||
ffi = true | ||
fuzz_runs = 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#!/bin/bash | ||
SOURCE=$(pwd) | ||
files=`find "$SOURCE" -type f -name "*$1"` | ||
|
||
for i in "${files[@]}" | ||
do | ||
huffc $i test | ||
location=${1:-"src"} | ||
extension=${2:-"*.t.huff"} | ||
format=${3:-"list"} | ||
|
||
files=`find $location -type f -name "$extension"` | ||
|
||
set -- junk $files | ||
shift | ||
for word; do | ||
huffc $word test --format $format | ||
done | ||
|
||
echo "Tests ran on" | ||
printf '%s\n' "${files[@]}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/// @title Test | ||
/// @author asnared <https://github.com/abigger87> | ||
/// @notice Example huff tests | ||
|
||
|
||
/// @notice Returns an incorrect sum | ||
#define macro BAD_SUM() = takes (2) returns (1) { | ||
// Input Stack: [a, b] | ||
sub // [sub] | ||
} | ||
|
||
|
||
/// @notice The example summing macro | ||
#define macro SUM() = takes (2) returns (1) { | ||
// Input Stack: [a, b] | ||
add // [sum] | ||
} | ||
|
||
/// @notice Helper macro to test two values are equal | ||
#define macro TEST_ASSERT_EQ() = { | ||
eq continue jumpi | ||
0x00 dup1 revert | ||
continue: | ||
} | ||
|
||
/// @notice Tests adding numbers | ||
#define test TEST_SUM() = { | ||
0x01 // [1] | ||
0x01 // [1, 1] | ||
SUM() // [sum] | ||
0x02 // [2, sum] | ||
TEST_ASSERT_EQ() | ||
continue jump | ||
|
||
fail: | ||
0x00 dup1 revert | ||
continue: | ||
} | ||
|
||
/// @notice Tests bad summation of numbers | ||
#define test FAIL_TEST_BAD_SUM() = { | ||
0x01 // [1] | ||
0x01 // [1, 1] | ||
BAD_SUM() // [sum] | ||
0x02 // [2, sum] | ||
TEST_ASSERT_EQ() | ||
continue jump | ||
|
||
// We should fail | ||
fail: | ||
0x00 dup1 revert | ||
continue: | ||
} | ||
|