From 64224d3918820ebcdd2ee23fe2e7678f94573345 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 27 Aug 2023 00:46:48 +0200 Subject: [PATCH 1/3] Make move_semantics5 a test --- exercises/move_semantics/move_semantics5.rs | 1 + info.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 68db09e..267bdcc 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -8,6 +8,7 @@ // I AM NOT DONE +#[test] fn main() { let mut x = 100; let y = &mut x; diff --git a/info.toml b/info.toml index e8a28cb..9267d46 100644 --- a/info.toml +++ b/info.toml @@ -340,7 +340,7 @@ So the end goal is to: [[exercises]] name = "move_semantics5" path = "exercises/move_semantics/move_semantics5.rs" -mode = "compile" +mode = "test" hint = """ Carefully reason about the range in which each mutable reference is in scope. Does it help to update the value of referent (x) immediately after From 16936d95d13df800f06c7af22069b5daf0c672e4 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 27 Aug 2023 00:47:03 +0200 Subject: [PATCH 2/3] Fix typo --- exercises/move_semantics/move_semantics3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics3.rs b/exercises/move_semantics/move_semantics3.rs index ea21493..16118f7 100644 --- a/exercises/move_semantics/move_semantics3.rs +++ b/exercises/move_semantics/move_semantics3.rs @@ -1,6 +1,6 @@ // move_semantics3.rs // -// Make me compile without adding new lines-- just changing existing lines! (no +// Make me compile without adding new lines -- just changing existing lines! (no // lines with multiple semicolons necessary!) // // Execute `rustlings hint move_semantics3` or use the `hint` watch subcommand From 193b600382ead22a24d2c26ca3a9117e7ad18be8 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 27 Aug 2023 01:06:01 +0200 Subject: [PATCH 3/3] Convert other exercises that have assertions to test mode --- exercises/iterators/iterators1.rs | 1 + exercises/smart_pointers/rc1.rs | 1 + exercises/threads/threads3.rs | 1 + info.toml | 6 +++--- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/exercises/iterators/iterators1.rs b/exercises/iterators/iterators1.rs index b3f698b..31076bb 100644 --- a/exercises/iterators/iterators1.rs +++ b/exercises/iterators/iterators1.rs @@ -11,6 +11,7 @@ // I AM NOT DONE +#[test] fn main() { let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"]; diff --git a/exercises/smart_pointers/rc1.rs b/exercises/smart_pointers/rc1.rs index ad3f1ce..1b90346 100644 --- a/exercises/smart_pointers/rc1.rs +++ b/exercises/smart_pointers/rc1.rs @@ -35,6 +35,7 @@ impl Planet { } } +#[test] fn main() { let sun = Rc::new(Sun {}); println!("reference count = {}", Rc::strong_count(&sun)); // 1 reference diff --git a/exercises/threads/threads3.rs b/exercises/threads/threads3.rs index db7d41b..91006bb 100644 --- a/exercises/threads/threads3.rs +++ b/exercises/threads/threads3.rs @@ -48,6 +48,7 @@ fn send_tx(q: Queue, tx: mpsc::Sender) -> () { }); } +#[test] fn main() { let (tx, rx) = mpsc::channel(); let queue = Queue::new(); diff --git a/info.toml b/info.toml index 9267d46..452e478 100644 --- a/info.toml +++ b/info.toml @@ -831,7 +831,7 @@ https://doc.rust-lang.org/stable/book/ch11-01-writing-tests.html#checking-for-pa [[exercises]] name = "iterators1" path = "exercises/iterators/iterators1.rs" -mode = "compile" +mode = "test" hint = """ Step 1: We need to apply something to the collection `my_fav_fruits` before we start to go through @@ -936,7 +936,7 @@ and try other types! [[exercises]] name = "rc1" path = "exercises/smart_pointers/rc1.rs" -mode = "compile" +mode = "test" hint = """ This is a straightforward exercise to use the Rc type. Each Planet has ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun. @@ -1025,7 +1025,7 @@ what you've learned :)""" [[exercises]] name = "threads3" path = "exercises/threads/threads3.rs" -mode = "compile" +mode = "test" hint = """ An alternate way to handle concurrency between threads is to use a mpsc (multiple producer, single consumer) channel to communicate.