goog.asserts
Namespacegoog.asserts.AssertionError
ClassError object for failed assertions. … more
.ENABLE_ASSERTS
.assert(condition, opt_message, var_args)
Checks if the condition evaluates to true if goog.asserts.ENABLE_ASSERTS is true.
condition
{*}
opt_message
{string
=}
var_args
{...*}
.assertArray(value, opt_message, var_args)
Checks if the value is an Array if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
Array
}
.assertBoolean(value, opt_message, var_args)
Checks if the value is a boolean if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
boolean
}
.assertFunction(value, opt_message, var_args)
Checks if the value is a function if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
Function
}
.assertInstanceof(value, type, opt_message, var_args)
Checks if the value is an instance of the user-defined type if goog.asserts.ENABLE_ASSERTS is true. The compiler may tighten the type returned by this function.
value
{*}
type
{!Function
}
opt_message
{string
=}
var_args
{...*}
Object
}
.assertNumber(value, opt_message, var_args)
Checks if the value is a number if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
number
}
.assertObject(value, opt_message, var_args)
Checks if the value is an Object if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
Object
}
.assertString(value, opt_message, var_args)
Checks if the value is a string if goog.asserts.ENABLE_ASSERTS is true.
value
{*}
opt_message
{string
=}
var_args
{...*}
string
}
.fail(opt_message, var_args)
Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case when we want to add a check in the unreachable area like switch-case statement:
switch(type) { case FOO: doSomething(); break; case BAR: doSomethingElse(); break; default: goog.assert.fail('Unrecognized type: ' + type); // We have only 2 types - "default:" section is unreachable code. }
opt_message
{string
=}
var_args
{...*}