Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate assert.markdown #1

Open
wants to merge 1 commit into
base: japanese
Choose a base branch
from
Open
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
91 changes: 82 additions & 9 deletions doc/api/assert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,112 @@

Stability: 5 - Locked

<!--
This module is used for writing unit tests for your applications, you can
access it with `require('assert')`.
-->

このモジュールはアプリケーションの単体テストを記述するために使用され、
`require('assert')` でアクセスできます。

## assert.fail(actual, expected, message, operator)

<!--
Throws an exception that displays the values for `actual` and `expected` separated by the provided operator.
-->

`actual` と `expected` を `operator` で区切ったメッセージを持つ例外を
スローします。

## assert(value, message), assert.ok(value[, message])
## assert(value[, message]), assert.ok(value[, message])

<!--
Tests if value is truthy, it is equivalent to `assert.equal(true, !!value, message);`
-->

`value` が truthy かテストします、
これは `assert.equal(true, !!value, message);` と等価です。

## assert.equal(actual, expected[, message])

<!--
Tests shallow, coercive equality with the equal comparison operator ( `==` ).
-->

`==` 演算子を強制して浅い同値性をテストします。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同値性( == )


## assert.notEqual(actual, expected[, message])

<!--
Tests shallow, coercive non-equality with the not equal comparison operator ( `!=` ).
-->

`!=` 演算子を強制して浅い非同値性をテストします。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非同値性( != )


## assert.deepEqual(actual, expected[, message])

Tests for deep equality. Primitive values are compared with the equal comparison
operator ( `==` ). Doesn't take object prototypes into account.
<!--
Tests for deep equality.
-->

深い同値性をテストします。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

深い同値性 ( === )


## assert.notDeepEqual(actual, expected[, message])

Tests for any deep inequality. Opposite of `assert.deepEqual`.
<!--
Tests for any deep inequality.
-->

深い非同値性をテストします。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepEqualと === の差を書くの難しいですね。
ここでは、
deepEqualとして、Object同士の比較をします。とか書きたくなります。


## assert.strictEqual(actual, expected[, message])

<!--
Tests strict equality, as determined by the strict equality operator ( `===` )
-->

`===` 演算子で厳密な同値性をテストします。

## assert.notStrictEqual(actual, expected[, message])

Tests strict non-equality, as determined by the strict not equal
operator ( `!==` )
<!--
Tests strict non-equality, as determined by the strict not equal operator ( `!==` )
-->

`!==` 演算子で厳密な非同値性をテストします。

## assert.deepStrictEqual(actual, expected[, message])

<!--
Tests for deep equality. Primitive values are compared with the strict equality
operator ( `===` ).
-->

深い同値性をテストします。プリミティブな値は厳密等価演算子 (`===`) で評価されます。

## assert.notDeepStrictEqual(actual, expected[, message])

<!--
Tests for deep inequality. Opposite of `assert.deepStrictEqual`.
-->

深い非同値性をテストします。`assert.deepStrictEqual`の反対です。

## assert.throws(block[, error][, message])

Expects `block` to throw an error. `error` can be constructor, `RegExp` or
<!--
Expects `block` to throw an error. `error` can be constructor, `RegExp` or
validation function.
-->

`block` がエラーをスローすることを期待します。
`error` はコンストラクタ、正規表現、または検証関数にすることができます。

<!--
Validate instanceof using constructor:
-->

コンストラクタを使って instanceof で検証:

assert.throws(
function() {
Expand All @@ -62,7 +116,11 @@ Validate instanceof using constructor:
Error
);

<!--
Validate error message using RegExp:
-->

正規表現を使ってエラーメッセージを検証:

assert.throws(
function() {
Expand All @@ -71,7 +129,11 @@ Validate error message using RegExp:
/value/
);

<!--
Custom error validation:
-->

独自のエラー検証:

assert.throws(
function() {
Expand All @@ -85,11 +147,22 @@ Custom error validation:
"unexpected error"
);

## assert.doesNotThrow(block[, message])
## assert.doesNotThrow(block, [message])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは assert.doesNotThrow(block[, message]) で良さそうに見えます。


<!--
Expects `block` not to throw an error, see assert.throws for details.
-->

Expects `block` not to throw an error, see `assert.throws` for details.
`block` がエラーをスローしないことを期待します。
詳細は assert.throws を参照してください。

## assert.ifError(value)

<!--
Tests if value is not a false value, throws if it is a true value. Useful when
testing the first argument, `error` in callbacks.
-->

`value` が false でないことをテストし、true だったらそれをスローします。
コールバックの第 1 引数である `error` をテストするのに便利です。