-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed test collection, added basic test (#245)
Co-authored-by: Jakub Ptak <[email protected]>
- Loading branch information
Showing
17 changed files
with
385 additions
and
15 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
8 changes: 8 additions & 0 deletions
8
starknet-foundry/crates/forge/tests/data/complex_structure_test/Scarb.toml
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,8 @@ | ||
[package] | ||
name = "test_multiple" | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest | ||
|
||
[dependencies] | ||
# foo = { path = "vendor/foo" } |
6 changes: 6 additions & 0 deletions
6
starknet-foundry/crates/forge/tests/data/complex_structure_test/fob.cairo
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,6 @@ | ||
use test_multiple::fob::fob_impl::fob_fn; | ||
|
||
#[test] | ||
fn test_fob() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} |
6 changes: 6 additions & 0 deletions
6
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fab.cairo
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,6 @@ | ||
mod fab_impl; | ||
|
||
#[test] | ||
fn test_simple() { | ||
assert(1 == 1, 1); | ||
} |
18 changes: 18 additions & 0 deletions
18
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fab/fab_impl.cairo
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,18 @@ | ||
use test_multiple::fib::fib_fn; | ||
|
||
fn fab_fn(a: felt252, b: felt252, n: felt252) -> felt252 { | ||
match n { | ||
0 => a, | ||
_ => fab_fn(b, a + b, n - 1), | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_fab() { | ||
assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_how_does_this_work() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} |
18 changes: 18 additions & 0 deletions
18
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fab/fibfabfob.cairo
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,18 @@ | ||
use test_multiple::fob::fob_impl::fob_fn; | ||
use test_multiple::fab::fab_impl::fab_fn; | ||
use test_multiple::fib::fib_fn; | ||
|
||
#[test] | ||
fn test_fib() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fob() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fab() { | ||
assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); | ||
} |
24 changes: 24 additions & 0 deletions
24
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fib.cairo
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,24 @@ | ||
use test_multiple::fob::fob_impl::fob_fn; | ||
use super::fab::fab_impl::fab_fn; | ||
|
||
fn fib_fn(a: felt252, b: felt252, n: felt252) -> felt252 { | ||
match n { | ||
0 => a, | ||
_ => fib_fn(b, a + b, n - 1), | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_fib() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fob_in_fib() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fab_in_fib() { | ||
assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); | ||
} |
6 changes: 6 additions & 0 deletions
6
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fob.cairo
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,6 @@ | ||
mod fob_impl; | ||
|
||
#[test] | ||
fn test_simple() { | ||
assert(1 == 1, 1); | ||
} |
18 changes: 18 additions & 0 deletions
18
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fob/fibfabfob.cairo
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,18 @@ | ||
use test_multiple::fob::fob_impl::fob_fn; | ||
use test_multiple::fab::fab_impl::fab_fn; | ||
use test_multiple::fib::fib_fn; | ||
|
||
#[test] | ||
fn test_fib() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fob() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fab() { | ||
assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); | ||
} |
11 changes: 11 additions & 0 deletions
11
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/fob/fob_impl.cairo
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,11 @@ | ||
fn fob_fn(a: felt252, b: felt252, n: felt252) -> felt252 { | ||
match n { | ||
0 => a, | ||
_ => fob_fn(b, a + b, n - 1), | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_fob() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} |
21 changes: 21 additions & 0 deletions
21
starknet-foundry/crates/forge/tests/data/complex_structure_test/src/lib.cairo
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,21 @@ | ||
mod fib; | ||
mod fob; | ||
mod fab; | ||
|
||
use fob::fob_impl::fob_fn; | ||
use fib::fib_fn; | ||
|
||
#[test] | ||
fn test_simple() { | ||
assert(1 == 1, 1); | ||
} | ||
|
||
#[test] | ||
fn test_fob_in_lib() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fib_in_lib() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} |
Empty file.
18 changes: 18 additions & 0 deletions
18
starknet-foundry/crates/forge/tests/data/complex_structure_test/tests/fibfabfob.cairo
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,18 @@ | ||
use test_multiple::fob::fob_impl::fob_fn; | ||
use test_multiple::fab::fab_impl::fab_fn; | ||
use test_multiple::fib::fib_fn; | ||
|
||
#[test] | ||
fn test_fib() { | ||
assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fob() { | ||
assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); | ||
} | ||
|
||
#[test] | ||
fn test_fab() { | ||
assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); | ||
} |
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,56 @@ | ||
use assert_fs::fixture::PathCopy; | ||
use indoc::indoc; | ||
|
||
use crate::e2e::common::runner::runner; | ||
|
||
#[test] | ||
fn complex_structure() { | ||
let temp = assert_fs::TempDir::new().unwrap(); | ||
temp.copy_from( | ||
"tests/data/complex_structure_test", | ||
&["**/*.cairo", "**/*.toml"], | ||
) | ||
.unwrap(); | ||
|
||
let snapbox = runner(); | ||
|
||
snapbox | ||
.current_dir(&temp) | ||
.assert() | ||
.success() | ||
.stdout_matches(indoc! {r#"Collected 21 test(s) and 11 test file(s) | ||
Running 1 test(s) from fob.cairo | ||
[PASS] fob::fob::test_fob | ||
Running 2 test(s) from src/fab/fab_impl.cairo | ||
[PASS] fab_impl::fab_impl::test_fab | ||
[PASS] fab_impl::fab_impl::test_how_does_this_work | ||
Running 3 test(s) from src/fab/fibfabfob.cairo | ||
[PASS] fibfabfob::fibfabfob::test_fib | ||
[PASS] fibfabfob::fibfabfob::test_fob | ||
[PASS] fibfabfob::fibfabfob::test_fab | ||
Running 1 test(s) from src/fab.cairo | ||
[PASS] fab::fab::test_simple | ||
Running 3 test(s) from src/fib.cairo | ||
[PASS] fib::fib::test_fib | ||
[PASS] fib::fib::test_fob_in_fib | ||
[PASS] fib::fib::test_fab_in_fib | ||
Running 3 test(s) from src/fob/fibfabfob.cairo | ||
[PASS] fibfabfob::fibfabfob::test_fib | ||
[PASS] fibfabfob::fibfabfob::test_fob | ||
[PASS] fibfabfob::fibfabfob::test_fab | ||
Running 1 test(s) from src/fob/fob_impl.cairo | ||
[PASS] fob_impl::fob_impl::test_fob | ||
Running 1 test(s) from src/fob.cairo | ||
[PASS] fob::fob::test_simple | ||
Running 3 test(s) from src/lib.cairo | ||
[PASS] src::test_simple | ||
[PASS] src::test_fob_in_lib | ||
[PASS] src::test_fib_in_lib | ||
Running 0 test(s) from tests/fab.cairo | ||
Running 3 test(s) from tests/fibfabfob.cairo | ||
[PASS] fibfabfob::fibfabfob::test_fib | ||
[PASS] fibfabfob::fibfabfob::test_fob | ||
[PASS] fibfabfob::fibfabfob::test_fab | ||
Tests: 21 passed, 0 failed, 0 skipped | ||
"#}); | ||
} |
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,2 +1,3 @@ | ||
mod collection; | ||
pub(crate) mod common; | ||
mod running; |
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
Oops, something went wrong.