diff --git a/tooling/nargo_cli/src/cli/init_cmd.rs b/tooling/nargo_cli/src/cli/init_cmd.rs index 2091ac89f9c..6dc7b9bd98e 100644 --- a/tooling/nargo_cli/src/cli/init_cmd.rs +++ b/tooling/nargo_cli/src/cli/init_cmd.rs @@ -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 diff --git a/tooling/nargo_cli/src/cli/noir_template_files/binary.nr b/tooling/nargo_cli/src/cli/noir_template_files/binary.nr new file mode 100644 index 00000000000..3c30bf08424 --- /dev/null +++ b/tooling/nargo_cli/src/cli/noir_template_files/binary.nr @@ -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); +} diff --git a/tooling/nargo_cli/src/cli/noir_template_files/contract.nr b/tooling/nargo_cli/src/cli/noir_template_files/contract.nr new file mode 100644 index 00000000000..e126726393d --- /dev/null +++ b/tooling/nargo_cli/src/cli/noir_template_files/contract.nr @@ -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)) } +} diff --git a/tooling/nargo_cli/src/cli/noir_template_files/library.nr b/tooling/nargo_cli/src/cli/noir_template_files/library.nr new file mode 100644 index 00000000000..b874c958a9b --- /dev/null +++ b/tooling/nargo_cli/src/cli/noir_template_files/library.nr @@ -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)); +}