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 conditionboolean the condition that is asserted to be true messagestring the message used when the condition is false -
<static> assertArray(target, message)
-
Asserts that the target object is an Array.
Parameters:
Name Type Description targetObject the target object to test messagestring an optional assertion failure message -
<static> assertArrayOrNull(target, message)
-
Asserts that the target object is an Array or null.
Parameters:
Name Type Description targetObject the target object to test messagestring an optional assertion failure message -
<static> assertBoolean(target, prefix)
-
Asserts that the target is a boolean.
Parameters:
Name Type Description targetObject the target object to test prefixstring 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 targetObject the target object to test prefixstring 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 targetObject the object to assert being a DOM Node and an HTML Element nodeNamestring 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 targetObject the object to assert being a DOM Node and an HTML Element or null nodeNamestring 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 targetObject the object to assert being a DOM Node depthnumber 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 targetObject the object to assert being a DOM Node or null depthnumber 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 targetObject the target object to test prefixstring 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 targetObject the target object to test prefixstring 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 keyObject the map key whose toString() result is used look up a value in the map theMapObject the map messagestring 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 messagestring the assertion failure message skipLevelnumber the optional number of stack trace levels to skip reasonstring 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 targetObject the target object to test prefixstring 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 targetObject the target object to test messagestring an optional assertion failure message -
<static> assertNumber(target, prefix)
-
Asserts that the target is a number.
Parameters:
Name Type Description targetObject the target object to test prefixstring 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 targetObject the target object to test prefixstring 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 targetObject the target object to test messagestring an optional assertion failure message -
<static> assertObject(target, prefix)
-
Asserts that the target is an Object.
Parameters:
Name Type Description targetObject the target object to test prefixstring 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 targetObject the target object to test prefixstring 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 targetObject the object to assert has a matching prototype theConstructorObject the type of object whose prototype will be compared reasonstring 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 targetObject the object to assert has a matching prototype or is null theConstructorObject the type of object whose prototype will be compared reasonstring 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 targetObject the object to assert has a matching prototype instanceOneObject one of the two possible types of objects whose prototype will be compared instanceTwoObject one of the two possible types of objects whose prototype will be compared reasonstring 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 targetObject the target object to test prefixstring 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 targetObject the target object to test prefixstring 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 targetObject the target object to test typestring typeof type that statisfies this condition prefixstring an optional prefix for the assertion failure message depthnumber an optional additional amount of levels to skip for the stack trace nullOKboolean 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
nullif the name can't be determined.Parameters:
Name Type Description funcfunction 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 depthnumber an optional additional amount of levels to skip for the stack trace Returns:
the stack trace- Type
- string