Skip to content

Commit a750e4a

Browse files
committed
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.
1 parent 1c789dd commit a750e4a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

exercises/error_handling/option1.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// on `None`. Handle this in a more graceful way than calling `unwrap`!
55
// Scroll down for hints :)
66

7-
fn main() {
7+
pub fn pop_too_much() -> bool {
88
let mut list = vec![3];
99

1010
let last = list.pop().unwrap();
@@ -15,9 +15,18 @@ fn main() {
1515
"The second-to-last item in the list is {:?}",
1616
second_to_last
1717
);
18+
true
1819
}
1920

21+
#[cfg(test)]
22+
mod tests {
23+
use super::*;
2024

25+
#[test]
26+
fn should_not_panic() {
27+
assert!(pop_too_much(), true);
28+
}
29+
}
2130

2231

2332

info.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ mode = "test"
192192

193193
[[exercises]]
194194
path = "exercises/error_handling/option1.rs"
195-
mode = "compile"
195+
mode = "test"
196196

197197
[[exercises]]
198198
path = "exercises/error_handling/result1.rs"

0 commit comments

Comments
 (0)