Skip to content

Commit

Permalink
Merge pull request rust-lang#1641 from mo8it/move-semantics5-test
Browse files Browse the repository at this point in the history
Convert exercises with assertions to tests
  • Loading branch information
shadows-withal committed Sep 6, 2023
2 parents 847b574 + 193b600 commit 4d04aad
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions exercises/iterators/iterators1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// I AM NOT DONE

#[test]
fn main() {
let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"];

Expand Down
2 changes: 1 addition & 1 deletion exercises/move_semantics/move_semantics3.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions exercises/move_semantics/move_semantics5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// I AM NOT DONE

#[test]
fn main() {
let mut x = 100;
let y = &mut x;
Expand Down
1 change: 1 addition & 0 deletions exercises/smart_pointers/rc1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl Planet {
}
}

#[test]
fn main() {
let sun = Rc::new(Sun {});
println!("reference count = {}", Rc::strong_count(&sun)); // 1 reference
Expand Down
1 change: 1 addition & 0 deletions exercises/threads/threads3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn send_tx(q: Queue, tx: mpsc::Sender<u32>) -> () {
});
}

#[test]
fn main() {
let (tx, rx) = mpsc::channel();
let queue = Queue::new();
Expand Down
8 changes: 4 additions & 4 deletions info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,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
Expand Down Expand Up @@ -827,7 +827,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
Expand Down Expand Up @@ -932,7 +932,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<T> type. Each Planet has
ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun.
Expand Down Expand Up @@ -1021,7 +1021,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.
Expand Down

0 comments on commit 4d04aad

Please sign in to comment.