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

chore: move noir program templates into separate files #3215

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 3 additions & 32 deletions tooling/nargo_cli/src/cli/init_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,9 @@ pub(crate) struct InitCommand {
pub(crate) contract: bool,
}

const BIN_EXAMPLE: &str = r#"fn main(x : Field, y : pub Field) {
assert(x != y);
}

#[test]
fn test_main() {
main(1, 2);

// Uncomment to make test fail
// main(1, 1);
}
"#;

const CONTRACT_EXAMPLE: &str = r#"contract Main {
internal fn double(x: Field) -> pub Field { x * 2 }
fn triple(x: Field) -> pub Field { x * 3 }
fn quadruple(x: Field) -> pub Field { double(double(x)) }
}
"#;

const LIB_EXAMPLE: &str = r#"fn my_util(x : Field, y : Field) -> bool {
x != y
}

#[test]
fn test_my_util() {
assert(my_util(1, 2));

// Uncomment to make test fail
// assert(my_util(1, 1));
}
"#;
const BIN_EXAMPLE: &str = include_str!("./noir_template_files/binary.nr");
const CONTRACT_EXAMPLE: &str = include_str!("./noir_template_files/contract.nr");
const LIB_EXAMPLE: &str = include_str!("./noir_template_files/library.nr");

pub(crate) fn run(
// Backend is currently unused, but we might want to use it to inform the "new" template in the future
Expand Down
11 changes: 11 additions & 0 deletions tooling/nargo_cli/src/cli/noir_template_files/binary.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main(x: Field, y: pub Field) {
assert(x != y);
}

#[test]
fn test_main() {
main(1, 2);

// Uncomment to make test fail
// main(1, 1);
}
5 changes: 5 additions & 0 deletions tooling/nargo_cli/src/cli/noir_template_files/contract.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
contract Main {
internal fn double(x: Field) -> pub Field { x * 2 }
fn triple(x: Field) -> pub Field { x * 3 }
fn quadruple(x: Field) -> pub Field { double(double(x)) }
}
11 changes: 11 additions & 0 deletions tooling/nargo_cli/src/cli/noir_template_files/library.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn not_equal(x: Field, y: Field) -> bool {
x != y
}

#[test]
fn test_not_equal() {
assert(not_equal(1, 2));

// Uncomment to make test fail
// assert(not_equal(1, 1));
}