Skip to content

Commit 55d97a1

Browse files
authored
Merge pull request #72 from woodyZootopia/chap-11-01-update
Chap-11-01 翻訳のアップデート
2 parents 37b63c2 + 9ad65b3 commit 55d97a1

File tree

9 files changed

+219
-481
lines changed

9 files changed

+219
-481
lines changed

listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod tests {
88

99
#[test]
1010
fn another() {
11+
//このテストを失敗させる
1112
panic!("Make this test fail");
1213
}
1314
}

listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct Guess {
66
impl Guess {
77
pub fn new(value: i32) -> Guess {
88
if value < 1 || value > 100 {
9+
//予想値は1から100の間でなければなりませんが、{}でした。
910
panic!("Guess value must be between 1 and 100, got {}.", value);
1011
}
1112

listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ impl Guess {
88
pub fn new(value: i32) -> Guess {
99
if value < 1 {
1010
panic!(
11+
//予想値は1以上でなければなりませんが、{}でした。
1112
"Guess value must be greater than or equal to 1, got {}.",
1213
value
1314
);
1415
} else if value > 100 {
1516
panic!(
17+
//予想値は100以下でなければなりませんが、{}でした。
1618
"Guess value must be less than or equal to 100, got {}.",
1719
value
1820
);
@@ -27,6 +29,7 @@ mod tests {
2729
use super::*;
2830

2931
#[test]
32+
//予想値は100以下でなければなりません
3033
#[should_panic(expected = "Guess value must be less than or equal to 100")]
3134
fn greater_than_100() {
3235
Guess::new(200);

listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ failures:
1111

1212
---- tests::larger_can_hold_smaller stdout ----
1313
thread 'main' panicked at 'assertion failed: larger.can_hold(&smaller)', src/lib.rs:28:9
14+
(スレッド'main'はsrc/lib.rs:28:9の'assertion failed: larger.can_hold(&smaller)'でパニックしました)
1415
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
1516

16-
1717
failures:
1818
tests::larger_can_hold_smaller
1919

listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod tests {
1212
let result = greeting("Carol");
1313
assert!(
1414
result.contains("Carol"),
15+
//挨拶(greeting)は名前を含んでいません。その値は`{}`でした
1516
"Greeting did not contain name, value was `{}`",
1617
result
1718
);

listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub struct Guess {
77
impl Guess {
88
pub fn new(value: i32) -> Guess {
99
if value < 1 {
10+
//予想値は1から100の間でなければなりませんが、{}でした。
1011
panic!("Guess value must be between 1 and 100, got {}.", value);
1112
}
1213

listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ impl Guess {
77
// ANCHOR: here
88
if value < 1 {
99
panic!(
10+
//予想値は100以下でなければなりませんが、{}でした。
1011
"Guess value must be less than or equal to 100, got {}.",
1112
value
1213
);
1314
} else if value > 100 {
1415
panic!(
16+
//予想値は1以上でなければなりませんが、{}でした。
1517
"Guess value must be greater than or equal to 1, got {}.",
1618
value
1719
);

src/ch11-01-writing-tests.md

Lines changed: 208 additions & 479 deletions
Large diffs are not rendered by default.

src/title-page.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Rust言語の2018 Editionには、Rustをもっと扱いやすく、学びやす
4747
-->
4848
- 7章「肥大化していくプロジェクトをパッケージ、クレート、モジュールを利用して管理する」はほとんど書き直されました。2018 Editionにおいてモジュールシステムとパスの仕組みはより一貫性を持つようになりました。
4949
- 10章には、新しい`impl Trait`構文を説明するために「引数としてのトレイト」と「トレイトを実装している型を返す」という新しい節があります。
50-
- 11章には、`?`演算子を使うテストの書き方を説明する "Using `Result<T, E>` in Tests" という新しい節があります。
50+
- 11章には、`?`演算子を使うテストの書き方を説明する`Result<T, E>`をテストで使う」という新しい節があります。
5151
- 19章の「高度なライフタイム」節はなくなりました。コンパイラの改善により、この節の内容が現れることはいっそう稀になったからです。
5252
- 付録D「マクロ」は、手続き的マクロも説明するようになり、19章の「マクロ」節に移動しました。
5353
- 付録A「キーワード」では、2015 Editionと2018 Editionで書かれたコードを一緒に使えるようにしてくれる、生識別子という新しい機能も説明します。

0 commit comments

Comments
 (0)