diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 0df39321e3f..c7ba255803a 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -809,11 +809,17 @@ fn main() { " } else { b"\ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/auto_git/out/src/lib.rs b/tests/testsuite/init/auto_git/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/auto_git/out/src/lib.rs +++ b/tests/testsuite/init/auto_git/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/formats_source/out/src/lib.rs b/tests/testsuite/init/formats_source/out/src/lib.rs index 059dc12384e..3b9acffd5ad 100644 --- a/tests/testsuite/init/formats_source/out/src/lib.rs +++ b/tests/testsuite/init/formats_source/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/fossil_autodetect/out/src/lib.rs b/tests/testsuite/init/fossil_autodetect/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/fossil_autodetect/out/src/lib.rs +++ b/tests/testsuite/init/fossil_autodetect/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/git_autodetect/out/src/lib.rs b/tests/testsuite/init/git_autodetect/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/git_autodetect/out/src/lib.rs +++ b/tests/testsuite/init/git_autodetect/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs b/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs +++ b/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs b/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs +++ b/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs b/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs +++ b/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/pijul_autodetect/out/src/lib.rs b/tests/testsuite/init/pijul_autodetect/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/pijul_autodetect/out/src/lib.rs +++ b/tests/testsuite/init/pijul_autodetect/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/simple_git/out/src/lib.rs b/tests/testsuite/init/simple_git/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/simple_git/out/src/lib.rs +++ b/tests/testsuite/init/simple_git/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs b/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs +++ b/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/simple_hg/out/src/lib.rs b/tests/testsuite/init/simple_hg/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/simple_hg/out/src/lib.rs +++ b/tests/testsuite/init/simple_hg/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs b/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs +++ b/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/init/simple_lib/out/src/lib.rs b/tests/testsuite/init/simple_lib/out/src/lib.rs index 1b4a90c9383..7d12d9af819 100644 --- a/tests/testsuite/init/simple_lib/out/src/lib.rs +++ b/tests/testsuite/init/simple_lib/out/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index ae23842c14f..92a5ed46555 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -39,11 +39,17 @@ fn simple_lib() { let contents = fs::read_to_string(&lib).unwrap(); assert_eq!( contents, - r#"#[cfg(test)] + r#"pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } }