Skip to content

Commit 254b966

Browse files
committed
Add tests for diagnostics
commit-id:34dd50be
1 parent 7a2a8a0 commit 254b966

File tree

33 files changed

+813
-22
lines changed

33 files changed

+813
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/forge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ tempfile.workspace = true
6666
cairo-lang-starknet-classes.workspace = true
6767
walkdir.workspace = true
6868
test-case.workspace = true
69+
itertools.workspace = true
6970
docs = { workspace = true, features = ["testing"] }
7071
packages_validation = { path = "../testing/packages_validation"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "attributes"
3+
version = "0.1.0"
4+
edition = "2024_07"
5+
6+
[dependencies]
7+
starknet = "2.9.3"
8+
9+
[dev-dependencies]
10+
snforge_std = { path = "../../../../../../snforge_std" }
11+
12+
[[target.starknet-contract]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use core::array::ArrayTrait;
2+
use core::result::ResultTrait;
3+
use snforge_std::cheatcodes::contract_class::DeclareResultTrait;
4+
use snforge_std::{ContractClassTrait, declare};
5+
6+
@attrs@
7+
fn call_and_invoke1(_a: felt252, b: u256) {
8+
let contract = declare("HelloStarknet").unwrap().contract_class();
9+
let constructor_calldata = @ArrayTrait::new();
10+
let (_contract_address1, _) = contract.deploy(constructor_calldata).unwrap()
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "generic"
3+
version = "0.1.0"
4+
edition = "2024_07"
5+
6+
[dependencies]
7+
starknet = "2.9.3"
8+
9+
[dev-dependencies]
10+
snforge_std = { path = "../../../../../../snforge_std" }
11+
12+
[[target.starknet-contract]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
fn smallest_element<T, impl TPartialOrd: PartialOrd<T>, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
2+
list: @Array<T>,
3+
) -> T {
4+
let mut smallest = *list[0];
5+
let mut index = 1;
6+
7+
while index < list.len() {
8+
if *list[index] < smallest {
9+
smallest = *list[index];
10+
}
11+
index = index + 1;
12+
}
13+
14+
smallest
15+
}
16+
17+
struct MyStruct {
18+
pub value: felt252,
19+
}
20+
21+
#[test]
22+
#[fuzzer]
23+
#[fork(url: "http://127.0.0.1:3030", block_tag: latest)]
24+
#[ignore]
25+
fn call_and_invoke(_a: felt252, b: u256) {
26+
let list: Array<MyStruct> = array![];
27+
28+
// We need to specify that we are passing a snapshot of `list` as an argument
29+
let s = smallest_element(@list);
30+
assert!(s == 3);
31+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "inline_macros"
3+
version = "0.1.0"
4+
edition = "2024_07"
5+
6+
[dependencies]
7+
starknet = "2.9.3"
8+
9+
[dev-dependencies]
10+
snforge_std = { path = "../../../../../../snforge_std" }
11+
12+
[[target.starknet-contract]]

0 commit comments

Comments
 (0)