1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 2<html> 3 <head> 4 <title>Tests for the Helper functions</title> 5<!-- 6 $Id: HelpersTestsIsAFunctions.html 108 2006-11-15 12:30:32Z wingedfox $ 7 $HeadURL: https://svn.debugger.ru/repos/jslibs/BrowserExtensions/tags/BrowserExtensions.001/tests/HelpersTestsIsAFunctions.html $ 8 9 Automated tests for the Helper is* functions 10 @author Ilya Lebedev <ilya@lebedev.net> 11--> 12 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 13 <title>BrowserExtensions/Helpers tests</title> 14 <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css"> 15 <script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script> 16 <script language="JavaScript" type="text/javascript" src="../helpers.js"></script> 17 <script language="JavaScript" type="text/javascript"> 18 function testIsUndefined() { 19 assertTrue("Check for undefined vs JSUNIT_UNDEFINED_VALUE", isUndefined(JSUNIT_UNDEFINED_VALUE)); 20 assertFalse("Check for undefined vs an empty array", isUndefined([])); 21 assertFalse("Check for undefined vs an empty object", isUndefined({})); 22 assertFalse("Check for undefined vs an empty string", isUndefined("")); 23 assertFalse("Check for undefined vs an string with content", isUndefined("test")); 24 assertFalse("Check for undefined vs 0", isUndefined(0)); 25 assertFalse("Check for undefined vs 1", isUndefined(1)); 26 assertFalse("Check for undefined vs function", isUndefined(function(){})); 27 } 28 function testIsFunction() { 29 assertFalse("Check for Function vs JSUNIT_UNDEFINED_VALUE" ,isFunction(JSUNIT_UNDEFINED_VALUE)); 30 assertFalse("Check for Function vs an empty array", isFunction([])); 31 assertFalse("Check for Function vs an empty object", isFunction({})); 32 assertFalse("Check for Function vs an empty string", isFunction("")); 33 assertFalse("Check for Function vs an string with content", isFunction("test")); 34 assertFalse("Check for Function vs 0", isFunction(0)); 35 assertFalse("Check for Function vs 1", isFunction(1)); 36 assertTrue("Check for Function vs Function", isFunction(function(){})); 37 } 38 function testIsString() { 39 assertFalse("Check for String vs JSUNIT_UNDEFINED_VALUE" ,isString(JSUNIT_UNDEFINED_VALUE)); 40 assertFalse("Check for String vs an empty array", isString([])); 41 assertFalse("Check for String vs an empty object", isString({})); 42 assertTrue("Check for String vs an empty string", isString("")); 43 assertTrue("Check for String vs an string with content", isString("test")); 44 assertFalse("Check for String vs 0", isString(0)); 45 assertFalse("Check for String vs 1", isString(1)); 46 assertFalse("Check for String vs Function", isString(function(){})); 47 } 48 function testIsNumber() { 49 assertFalse("Check for Number vs JSUNIT_UNDEFINED_VALUE" ,isNumber(JSUNIT_UNDEFINED_VALUE)); 50 assertFalse("Check for Number vs an empty array", isNumber([])); 51 assertFalse("Check for Number vs an empty object", isNumber({})); 52 assertFalse("Check for Number vs an empty String", isNumber("")); 53 assertFalse("Check for Number vs an String with content", isNumber("test")); 54 assertTrue("Check for Number vs 0", isNumber(0)); 55 assertTrue("Check for Number vs 1", isNumber(1)); 56 assertFalse("Check for Number vs Function", isNumber(function(){})); 57 } 58 function testIsNumeric() { 59 assertFalse("Check for Numeric (calculable) value vs JSUNIT_UNDEFINED_VALUE" ,isNumeric(JSUNIT_UNDEFINED_VALUE)); 60 assertFalse("Check for Numeric (calculable) value vs an empty array", isNumeric([])); 61 assertFalse("Check for Numeric (calculable) value vs an empty object", isNumeric({})); 62 assertFalse("Check for Numeric (calculable) value vs an empty String", isNumeric("")); 63 assertFalse("Check for Numeric (calculable) value vs an String with content", isNumeric("test")); 64 assertTrue("Check for Numeric (calculable) value vs 0", isNumeric(0)); 65 assertTrue("Check for Numeric (calculable) value vs 1", isNumeric(1)); 66 assertTrue("Check for Numeric (calculable) value vs Number.MAX_VALUE", isNumeric(Number.MAX_VALUE)); 67 assertTrue("Check for Numeric (calculable) value vs Number.MIN_VALUE", isNumeric(Number.MIN_VALUE)); 68 assertFalse("Check for Numeric (calculable) value vs Number.NEGATIVE_INFINITY", isNumeric(Number.NEGATIVE_INFINITY)); 69 assertFalse("Check for Numeric (calculable) value vs Number.POSITIVE_INFINITY", isNumeric(Number.POSITIVE_INFINITY)); 70 assertFalse("Check for Numeric (calculable) value vs Number.NaN", isNumeric(Number.NaN)); 71 assertFalse("Check for Numeric (calculable) value vs Function", isNumeric(function(){})); 72 } 73 function testIsArray() { 74 assertFalse("Check for Array vs JSUNIT_UNDEFINED_VALUE" ,isArray(JSUNIT_UNDEFINED_VALUE)); 75 assertTrue("Check for Array vs an empty array", isArray([])); 76 assertTrue("Check for Array vs an array", isArray([1])); 77 assertFalse("Check for Array vs an empty object", isArray({})); 78 assertFalse("Check for Array vs an empty String", isArray("")); 79 assertFalse("Check for Array vs an String with content", isArray("test")); 80 assertFalse("Check for Array vs 0", isArray(0)); 81 assertFalse("Check for Array vs 1", isArray(1)); 82 assertFalse("Check for Array vs Function", isArray(function(){})); 83 } 84 function testIsRegExp() { 85 assertFalse("Check for RegExp vs JSUNIT_UNDEFINED_VALUE" ,isRegExp(JSUNIT_UNDEFINED_VALUE)); 86 assertFalse("Check for RegExp vs an empty array", isRegExp([])); 87 assertFalse("Check for RegExp vs an empty object", isRegExp({})); 88 assertFalse("Check for RegExp vs an empty String", isRegExp("")); 89 assertFalse("Check for RegExp vs an String with content", isRegExp("test")); 90 assertFalse("Check for RegExp vs 0", isRegExp(0)); 91 assertFalse("Check for RegExp vs 1", isRegExp(1)); 92 assertFalse("Check for RegExp vs Function", isRegExp(function(){})); 93 assertTrue("Check for RegExp vs RegExp", isRegExp(new RegExp("/a/"))); 94 assertTrue("Check for RegExp vs /regexp/", isRegExp(/a/)); 95 } 96 function testIsBoolean() { 97 assertFalse("Check for Boolean vs JSUNIT_UNDEFINED_VALUE" ,isBoolean(JSUNIT_UNDEFINED_VALUE)); 98 assertTrue("Check for Boolean vs a true", isBoolean(true)); 99 assertTrue("Check for Boolean vs a false", isBoolean(false)); 100 assertFalse("Check for Boolean vs an empty array", isBoolean([])); 101 assertFalse("Check for Boolean vs an empty object", isBoolean({})); 102 assertFalse("Check for Boolean vs an empty String", isBoolean("")); 103 assertFalse("Check for Boolean vs an String with content", isBoolean("test")); 104 assertFalse("Check for Boolean vs 0", isBoolean(0)); 105 assertFalse("Check for Boolean vs 1", isBoolean(1)); 106 assertFalse("Check for Boolean vs Function", isBoolean(function(){})); 107 assertFalse("Check for Boolean vs RegExp", isBoolean(new RegExp("/a/"))); 108 assertFalse("Check for Boolean vs /regexp/", isBoolean(/a/)); 109 } 110 function testIsEmpty() { 111 assertTrue("Check for Empty value vs JSUNIT_UNDEFINED_VALUE" ,isEmpty(JSUNIT_UNDEFINED_VALUE)); 112 assertTrue("Check for Empty value vs an empty array", isEmpty([])); 113 assertFalse("Check for Empty value vs an array with values", isEmpty([1,2])); 114 assertTrue("Check for Empty value vs an empty object", isEmpty({})); 115 assertFalse("Check for Empty value vs an object with values", isEmpty({'a':'b'})); 116 assertTrue("Check for Empty value vs an empty String", isEmpty("")); 117 assertFalse("Check for Empty value vs an String with spaces", isEmpty(" ")); 118 assertFalse("Check for Empty value vs an String with content", isEmpty("test")); 119 assertTrue("Check for Empty value vs 0", isEmpty(0)); 120 assertFalse("Check for Empty value vs 1", isEmpty(1)); 121 assertFalse("Check for Empty value vs Function", isEmpty(function(){})); 122 assertTrue("Check for Empty value vs empty dynamic RegExp", isEmpty(new RegExp(""))); 123 } 124 125 </script> 126 </head> 127 <body> 128 <h1>Tests for the Helpers functions</h1> 129 <p>This page contains tests for the Helpers functions. To see them, take a look at the source.</p> 130 </body> 131</html> 132