Assertion utilities.
The container is expected to have already initialized the Assert Object before this
code is executed and initialized the adf.mf.api.AdfAssert.DEBUG flag.
Methods
-
<static> assert(condition, message)
-
Asserts that a condition is true. If the condition does not evaluate to true, an exception is thrown with the optional message and reason.
Parameters:
Name Type Description condition
boolean the condition that is asserted to be true message
string the message used when the condition is false -
<static> assertArray(target, message)
-
Asserts that the target object is an Array.
Parameters:
Name Type Description target
Object the target object to test message
string an optional assertion failure message -
<static> assertArrayOrNull(target, message)
-
Asserts that the target object is an Array or null.
Parameters:
Name Type Description target
Object the target object to test message
string an optional assertion failure message -
<static> assertBoolean(target, prefix)
-
Asserts that the target is a boolean.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertBooleanOrNull(target, prefix)
-
Asserts that the target is a boolean or null.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertDomElement(target, nodeName)
-
Asserts that the target is a DOM Element and optionally has the specified element name.
Parameters:
Name Type Description target
Object the object to assert being a DOM Node and an HTML Element nodeName
string the optional name of the element to also assert upon -
<static> assertDomElementOrNull(target, nodeName)
-
Asserts that the target is a DOM Element and optionally has the specified element name.
Parameters:
Name Type Description target
Object the object to assert being a DOM Node and an HTML Element or null nodeName
string the optional name of the element to also assert upon -
<static> assertDomNode(target, depth)
-
Asserts that the target is a DOM Node.
Parameters:
Name Type Description target
Object the object to assert being a DOM Node depth
number an optional additional amount of levels to skip for the stack trace -
<static> assertDomNodeOrNull(target, depth)
-
Asserts that the target is a DOM Node or null.
Parameters:
Name Type Description target
Object the object to assert being a DOM Node or null depth
number an optional additional amount of levels to skip for the stack trace -
<static> assertFunction(target, prefix)
-
Asserts that the target is a Function.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertFunctionOrNull(target, prefix)
-
Asserts that the target is a Function or null.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertInMap(key, theMap, message)
-
Asserts that key String corresponds to an entry in the Map.
Parameters:
Name Type Description key
Object the map key whose toString() result is used look up a value in the map theMap
Object the map message
string an optional assertion failure message -
<static> assertionFailed(message, skipLevel, reason)
-
Base assertion failure support that supports specifying the stack skipping level.
Parameters:
Name Type Description message
string the assertion failure message skipLevel
number the optional number of stack trace levels to skip reason
string the optional reason for the assertion Throws:
Error with the given message and stack trace details if available. -
<static> assertNonEmptyString(target, prefix)
-
Asserts that the target is a non-empty String.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertNonNumeric(target, message)
-
Asserts that the target object is not either a number, or convertible to a number.
Parameters:
Name Type Description target
Object the target object to test message
string an optional assertion failure message -
<static> assertNumber(target, prefix)
-
Asserts that the target is a number.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertNumberOrNull(target, prefix)
-
Asserts that the target is a number or null.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertNumeric(target, message)
-
Asserts that the target object is either a number, or convertible to a number.
Parameters:
Name Type Description target
Object the target object to test message
string an optional assertion failure message -
<static> assertObject(target, prefix)
-
Asserts that the target is an Object.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertObjectOrNull(target, prefix)
-
Asserts that the target is an Object or null.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertPrototype(target, theConstructor, reason)
-
Asserts that the the target object has the same prototype as the example type.
Parameters:
Name Type Description target
Object the object to assert has a matching prototype theConstructor
Object the type of object whose prototype will be compared reason
string the message used when the prototype does not match -
<static> assertPrototypeOrNull(target, theConstructor, reason)
-
Asserts that the the target object has the same prototype as the example type or is null.
Parameters:
Name Type Description target
Object the object to assert has a matching prototype or is null theConstructor
Object the type of object whose prototype will be compared reason
string the message used when the prototype does not match -
<static> assertPrototypes(target, instanceOne, instanceTwo, reason)
-
Asserts that the the target object has the same prototype as one of the example types.
Parameters:
Name Type Description target
Object the object to assert has a matching prototype instanceOne
Object one of the two possible types of objects whose prototype will be compared instanceTwo
Object one of the two possible types of objects whose prototype will be compared reason
string the message used when the prototype does not match at least one of the prototypes -
<static> assertString(target, prefix)
-
Asserts that the target is a String.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertStringOrNull(target, prefix)
-
Asserts that the target is a String or null.
Parameters:
Name Type Description target
Object the target object to test prefix
string an optional prefix for the assertion failure message -
<static> assertType(target, type, prefix, depth, nullOK)
-
Asserts that the target object has the typeof specified.
Parameters:
Name Type Description target
Object the target object to test type
string typeof type that statisfies this condition prefix
string an optional prefix for the assertion failure message depth
number an optional additional amount of levels to skip for the stack trace nullOK
boolean true if a null value satisfies this condition -
<static> failedInAbstractFunction()
-
Convenience function for asserting when an abstact function is called.
-
<static> forceDebug()
-
Forces assertion DEBUG to be set to true (to display assertions).
-
<static> getFunctionName(func) → {string}
-
Returns the name of a function, or
null
if the name can't be determined.Parameters:
Name Type Description func
function the function Returns:
the name of the function or null- Type
- string
-
<static> getStackString(depth) → {string}
-
Returns the stack trace as a string.
Parameters:
Name Type Description depth
number an optional additional amount of levels to skip for the stack trace Returns:
the stack trace- Type
- string