Skip to content
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 monomorphized AST #240

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.vscode
src/tests/snapshots/snapshots
Binary file added src/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions src/mast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ fn monomorphize_expr<B: Backend>(
}

// retrieve the function signature
dbg!(module);
dbg!(&fn_name.value);
let old_qualified = FullyQualified::new(module, &fn_name.value);
let mut fn_info = ctx
.tast
Expand Down
21 changes: 1 addition & 20 deletions src/negative_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn tast_pass(code: &str) -> (Result<usize>, TypeChecker<R1csBackend>, Sources) {
(res, tast, source)
}

fn mast_pass(code: &str) -> Result<Mast<R1csBackend>> {
pub fn mast_pass(code: &str) -> Result<Mast<R1csBackend>> {
let (_, tast, _) = tast_pass(code);
crate::mast::monomorphize(tast)
}
Expand Down Expand Up @@ -801,22 +801,3 @@ fn test_monomorphize_returntype_mismatch() {
ErrorKind::ReturnTypeMismatch(..),
));
}


#[test]
fn test_simple_mast() {
let code = r#"
struct Thing {
val: Field,
}
fn main(xx: Field) -> Thing {
let mut thing = Thing { val: 3 };
thing.val = xx;
return thing;
}
"#;

let mast = mast_pass(code).unwrap();

insta::assert_snapshot!(serde_json::to_string(&mast).unwrap());
}
6 changes: 0 additions & 6 deletions src/snapshots/noname__negative_tests__simple_mast.snap

This file was deleted.

6 changes: 0 additions & 6 deletions src/snapshots/noname__negative_tests__simple_mast.snap.new

This file was deleted.

Binary file added src/tests/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod examples;
mod modules;
mod snapshots;
mod stdlib;
2 changes: 2 additions & 0 deletions src/tests/snapshots.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[cfg(test)]
mod mast;
Loading