Yahoo! UI Library

yuitest  2.5.0

Yahoo! UI Library > yuitest > YAHOO.util.Assert

Show Private Show Protected

static Class YAHOO.util.Assert

The Assert object provides functions to test JavaScript values against known and expected results. Whenever a comparison (assertion) fails, an error is thrown.

Methods

areEqual

static void areEqual ( expected , actual , message )
Asserts that a value is equal to another. This uses the double equals sign so type cohersion may occur.
Parameters:
expected <Object> The expected value.
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

areNotEqual

static void areNotEqual ( unexpected , actual , message )
Asserts that a value is not equal to another. This uses the double equals sign so type cohersion may occur.
Parameters:
unexpected <Object> The unexpected value.
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

areNotSame

static void areNotSame ( unexpected , actual , message )
Asserts that a value is not the same as another. This uses the triple equals sign so no type cohersion may occur.
Parameters:
unexpected <Object> The unexpected value.
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

areSame

static void areSame ( expected , actual , message )
Asserts that a value is the same as another. This uses the triple equals sign so no type cohersion may occur.
Parameters:
expected <Object> The expected value.
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

fail

static void fail ( message )
Forces an assertion error to occur.
Parameters:
message <String> (Optional) The message to display with the failure.
Returns: void

isArray

static void isArray ( actual , message )
Asserts that a value is an array.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isBoolean

static void isBoolean ( actual , message )
Asserts that a value is a Boolean.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isFalse

static void isFalse ( actual , message )
Asserts that a value is false. This uses the triple equals sign so no type cohersion may occur.
Parameters:
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isFunction

static void isFunction ( actual , message )
Asserts that a value is a function.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isInstanceOf

static void isInstanceOf ( expected , actual , message )
Asserts that a value is an instance of a particular object. This may return incorrect results when comparing objects from one frame to constructors in another frame. For best results, don't use in a cross-frame manner.
Parameters:
expected <Function> The function that the object should be an instance of.
actual <Object> The object to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNaN

static void isNaN ( actual , message )
Asserts that a value is not a number.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNotNaN

static void isNotNaN ( actual , message )
Asserts that a value is not the special NaN value.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNotNull

static void isNotNull ( actual , message )
Asserts that a value is not null. This uses the triple equals sign so no type cohersion may occur.
Parameters:
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNotUndefined

static void isNotUndefined ( actual , message )
Asserts that a value is not undefined. This uses the triple equals sign so no type cohersion may occur.
Parameters:
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNull

static void isNull ( actual , message )
Asserts that a value is null. This uses the triple equals sign so no type cohersion may occur.
Parameters:
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isNumber

static void isNumber ( actual , message )
Asserts that a value is a number.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isObject

static void isObject ( actual , message )
Asserts that a value is an object.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isString

static void isString ( actual , message )
Asserts that a value is a string.
Parameters:
actual <Object> The value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isTrue

static void isTrue ( actual , message )
Asserts that a value is true. This uses the triple equals sign so no type cohersion may occur.
Parameters:
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isTypeOf

static void isTypeOf ( expectedType , actualValue , message )
Asserts that a value is of a particular type.
Parameters:
expectedType <String> The expected type of the variable.
actualValue <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void

isUndefined

static void isUndefined ( expected , actual , message )
Asserts that a value is undefined. This uses the triple equals sign so no type cohersion may occur.
Parameters:
expected <Object> The expected value.
actual <Object> The actual value to test.
message <String> (Optional) The message to display if the assertion fails.
Returns: void


Copyright © 2007 Yahoo! Inc. All rights reserved.