Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Change 'fail!' to 'panic!' in text and code #113

Merged
merged 1 commit into from
Dec 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/chapter-04.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Bam! Now let's make it fail:
~~~ {.rust}
#[test]
fn this_tests_code() {
fail!("Fail!");
panic!("Fail!");
}
~~~

Expand Down
16 changes: 8 additions & 8 deletions book/chapter-05.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ First, a test. This will go in fizzbuzz.rs:
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}
~~~
Expand All @@ -45,7 +45,7 @@ fn div_by_three(num: int) -> bool {
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}
~~~
Expand Down Expand Up @@ -96,7 +96,7 @@ fn div_by_three(num: int) -> bool {
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}
~~~
Expand Down Expand Up @@ -125,14 +125,14 @@ fn div_by_three(num: int) -> bool {
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}

#[test]
fn test_div_by_three_with_three() {
if !div_by_three(3) {
fail!("Three should be three");
panic!("Three should be three");
}
}
~~~
Expand Down Expand Up @@ -178,14 +178,14 @@ fn div_by_three(num: int) -> bool {
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}

#[test]
fn test_div_by_three_with_three() {
if !div_by_three(3) {
fail!("Three should be three");
panic!("Three should be three");
}
}
~~~
Expand Down Expand Up @@ -485,7 +485,7 @@ fn main() {

It's more compact, and removes the intermediate variable all together.

We can do one other thing too: this whole `if/fail!` thing so common in
We can do one other thing too: this whole `if/panic!` thing so common in
tests seems too complex. Why do we have to write if over and over and
over again? Meet `assert!`:

Expand Down
2 changes: 1 addition & 1 deletion code/04/testing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[test]
fn this_tests_code() {
fail!("Fail!");
panic!("Fail!");
}
12 changes: 6 additions & 6 deletions code/05/fizzbuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@ fn div_by_fifteen(num: int) -> bool {
#[test]
fn test_div_by_three() {
if div_by_three(1) {
fail!("One is not three");
panic!("One is not three");
}
}

#[test]
fn test_div_by_three_with_three() {
if !div_by_three(3) {
fail!("Three should be three");
panic!("Three should be three");
}
}

#[test]
fn test_div_by_five() {
if div_by_five(1) {
fail!("One is not five");
panic!("One is not five");
}
}

#[test]
fn test_div_by_five_with_five() {
if !div_by_five(5) {
fail!("Five should be five");
panic!("Five should be five");
}
}

#[test]
fn test_div_by_fifteen() {
if div_by_fifteen(1) {
fail!("One is not fifteen");
panic!("One is not fifteen");
}
}

#[test]
fn test_div_by_fifteen_with_fifteen() {
if !div_by_fifteen(15) {
fail!("Fifteen should be fifteen");
panic!("Fifteen should be fifteen");
}
}