-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test adding programs using non squashed Felt252Dict #1797
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
35ed2dc
adding programs using non squshed Felt252
FrancoGiachetta bc9aa71
update CHANGELOG.md
FrancoGiachetta 14f498b
update CHANGELOG.md
FrancoGiachetta 89afb57
add tests
FrancoGiachetta 4c203ed
update CHANGELOG.md
FrancoGiachetta fe81f82
change CHANGELOG + lint
FrancoGiachetta 974c209
making requested changes
FrancoGiachetta ffbccac
linting
FrancoGiachetta 0f36fb5
linting
FrancoGiachetta e6575e1
clarifying tests
FrancoGiachetta 72cf8e2
comment fixing
FrancoGiachetta 320c86c
Merge branch 'main' into test/cario_felt252_dict
pefontana 9f111a6
requested changes
FrancoGiachetta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Binary file not shown.
28 changes: 28 additions & 0 deletions
28
cairo_programs/cairo-1-programs/dict_non_squashed/dict_with_struct_non_squash.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,28 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
|
||
#[derive(Drop, Copy)] | ||
struct FP16x16 { | ||
mag: u32, | ||
sign: bool | ||
} | ||
|
||
fn main() -> Felt252Dict<Nullable<FP16x16>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<FP16x16>> = Default::default(); | ||
|
||
let box_a = BoxTrait::new(identity(FP16x16 { mag: 1, sign: false })); | ||
let box_b = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
let box_c = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
|
||
// Insert it as a `Span` | ||
d.insert(0, nullable_from_box(box_c)); | ||
d.insert(1, nullable_from_box(box_a)); | ||
d.insert(2, nullable_from_box(box_b)); | ||
|
||
d | ||
} | ||
|
||
// TODO: remove this temporary fix once fixed in cairo | ||
#[inline(never)] | ||
fn identity<T>(t: T) -> T { t } |
15 changes: 15 additions & 0 deletions
15
cairo_programs/cairo-1-programs/dict_non_squashed/felt_dict_non_squash.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,15 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
fn main() -> Felt252Dict<Nullable<Span<felt252>>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default(); | ||
|
||
// Create the array to insert | ||
let a = array![8, 9, 10, 11]; | ||
let b = array![1, 2, 3]; | ||
|
||
// Insert it as a `Span` | ||
d.insert(66675, nullable_from_box(BoxTrait::new(a.span()))); | ||
d.insert(66676, nullable_from_box(BoxTrait::new(b.span()))); | ||
d | ||
} |
23 changes: 23 additions & 0 deletions
23
cairo_programs/cairo-1-programs/dict_non_squashed/nullable_box_vec_non_squash.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,23 @@ | ||
struct NullableVec<T> { | ||
items: Felt252Dict<Nullable<Box<T>>>, | ||
len: usize, | ||
} | ||
|
||
fn main() -> NullableVec<u32> { | ||
let mut d: Felt252Dict<Nullable<Box<u32>>> = Default::default(); | ||
|
||
// Populate the dictionary | ||
d.insert(0, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(10))))); | ||
d.insert(1, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(20))))); | ||
d.insert(2, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(30))))); | ||
|
||
// Return NullableVec | ||
NullableVec { | ||
items: d, | ||
len: 3, | ||
} | ||
} | ||
|
||
// TODO: remove this temporary fix once fixed in cairo | ||
#[inline(never)] | ||
fn identity<T>(t: T) -> T { t } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here explaining why we test these programs in a different way than the others