Namespace goog.testing.asserts

code »
Show:

Type Definitions

Global Functions

Runs a function in an environment where test failures are not logged. This is useful for testing test code, where failures can be a normal part of a test.

Parameters
fn: function(): void
Function to run without logging failures.
code »goog.testing.asserts.contains_ ( container, contained )boolean

Tells whether the array contains the given element.

Parameters
container: goog.testing.asserts.ArrayLike
The array to find the element in.
contained: *
Element to find.
Returns
Whether the element is in the array.
code »goog.testing.asserts.findDifferences ( expected, actual, opt_equalityPredicate )?string

Determines if two items of any type match, and formulates an error message if not.

Parameters
expected: *
Expected argument to match.
actual: *
Argument as a result of performing the test.
opt_equalityPredicate: (function(string, *, *): ?string)=
An optional function that can be used to check equality of variables. It accepts 3 arguments: type-of-variables, var1, var2 (in that order) and returns an error message if the variables are not equal, goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL if the variables are equal, or goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS if the predicate couldn't check the input variables. The function will be called only if the types of var1 and var2 are identical.
Returns
Null on success, error message on failure.
Parameters
expected: *
The expected value.
actual: *
The actual value.
Returns
A failure message of the values don't match.
code »goog.testing.asserts.indexOf_ ( container, contained )number

Finds the position of the first occurrence of an element in a container.

Parameters
container: goog.testing.asserts.ArrayLike
The array to find the element in.
contained: *
Element to find.
Returns
Index of the first occurrence or -1 if not found.

Helper function for assertObjectEquals.

Parameters
prop: string
A property name.
Returns
If the property name is an array index.

Compares equality of two numbers, allowing them to differ up to a given tolerance.

Parameters
var1: number
A number.
var2: number
A number.
tolerance: number
the maximum allowed difference.
Returns
Whether the two variables are sufficiently close.

Raises a JsUnit exception with the given comment.

Parameters
comment: string
A summary for the exception.
opt_message: string=
A description of the exception.

Converts an array like object to array or clones it if it's already array.

Parameters
arrayLike: goog.testing.asserts.ArrayLike
The collection.
Returns
Copy of the collection as array.

Global Properties

The return value of the equality predicate passed to findDifferences below, in cases where the predicate can't test the input variables for equality.

The return value of the equality predicate passed to findDifferences below, in cases where the input vriables are equal.