mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 00:00:03 +03:00
fix(option1): Add test for prematurely passing exercise
Fixes the bug referenced in #160, but does not address the larger feature work referenced by the issue.
This commit is contained in:
parent
1c789dda08
commit
a750e4a1a3
|
@ -4,7 +4,7 @@
|
||||||
// on `None`. Handle this in a more graceful way than calling `unwrap`!
|
// on `None`. Handle this in a more graceful way than calling `unwrap`!
|
||||||
// Scroll down for hints :)
|
// Scroll down for hints :)
|
||||||
|
|
||||||
fn main() {
|
pub fn pop_too_much() -> bool {
|
||||||
let mut list = vec![3];
|
let mut list = vec![3];
|
||||||
|
|
||||||
let last = list.pop().unwrap();
|
let last = list.pop().unwrap();
|
||||||
|
@ -15,9 +15,18 @@ fn main() {
|
||||||
"The second-to-last item in the list is {:?}",
|
"The second-to-last item in the list is {:?}",
|
||||||
second_to_last
|
second_to_last
|
||||||
);
|
);
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_not_panic() {
|
||||||
|
assert!(pop_too_much(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ mode = "test"
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
path = "exercises/error_handling/option1.rs"
|
path = "exercises/error_handling/option1.rs"
|
||||||
mode = "compile"
|
mode = "test"
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
path = "exercises/error_handling/result1.rs"
|
path = "exercises/error_handling/result1.rs"
|
||||||
|
|
Loading…
Reference in a new issue