From: Robert Konigsberg Date: Mon, 17 Oct 2011 16:38:37 +0000 (-0400) Subject: Move to JSTD133 X-Git-Tag: v1.0.0~414^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=1a27bd14b2938f17a3a9896d64645892a6b26a1e;p=dygraphs.git Move to JSTD133 --- diff --git a/README b/README index 5ec6aa9..370db4e 100644 --- a/README +++ b/README @@ -58,7 +58,7 @@ dygraphs uses: automated tests use: - auto_tests/lib/jquery-1.4.2.js (MIT & GPL2) - auto_tests/lib/Asserts.js (Apache 2.0 License) - - auto-tests/lib/JsTestDriver-1.3.2.jar (Apache 2.0 License + - auto-tests/lib/JsTestDriver-1.3.3cjar (Apache 2.0 License rgbcolor: http://www.phpied.com/rgb-color-parser-in-javascript/ strftime: http://tech.bluesmoon.info/2008/04/strftime-in-javascript.html diff --git a/auto_tests/README b/auto_tests/README index caf0bea..e5ec593 100644 --- a/auto_tests/README +++ b/auto_tests/README @@ -11,7 +11,7 @@ Running tests browser: Run: - $ java -jar ./auto_tests/lib/JsTestDriver-1.3.2.jar --port 9876 + $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --port 9876 Open http://localhost:9876/capture @@ -19,7 +19,7 @@ Running tests - Run the tests with: - $ java -jar ./auto_tests/lib/JsTestDriver-1.3.2.jar --tests all + $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --tests all Debugging tests diff --git a/auto_tests/lib/Asserts.js b/auto_tests/lib/Asserts.js index b3ed441..0059ce0 100644 --- a/auto_tests/lib/Asserts.js +++ b/auto_tests/lib/Asserts.js @@ -1,25 +1,23 @@ -/* - * Copyright 2009 Google Inc. - * +opyright 2009 Google Inc. + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ - function expectAsserts(count) { jstestdriver.expectedAssertCount = count; } -this.fail = function fail(msg) { +var fail = function fail(msg) { var err = new Error(msg); err.name = 'AssertError'; @@ -28,15 +26,16 @@ this.fail = function fail(msg) { } throw err; -} +}; function isBoolean_(bool) { if (typeof(bool) != 'boolean') { - this.fail('Not a boolean: ' + this.prettyPrintEntity_(bool)); + fail('Not a boolean: ' + prettyPrintEntity_(bool)); } } + var isElement_ = (function () { var div = document.createElement('div'); @@ -56,28 +55,30 @@ var isElement_ = (function () { }; }()); + function formatElement_(el) { var tagName; try { tagName = el.tagName.toLowerCase(); - var str = "<" + tagName; + var str = '<' + tagName; var attrs = el.attributes, attribute; for (var i = 0, l = attrs.length; i < l; i++) { attribute = attrs.item(i); if (!!attribute.nodeValue) { - str += " " + attribute.nodeName + "=\"" + attribute.nodeValue + "\""; + str += ' ' + attribute.nodeName + '=\"' + attribute.nodeValue + '\"'; } } - return str + ">..."; + return str + '>...'; } catch (e) { - return "[Element]" + (!!tagName ? " " + tagName : ""); + return '[Element]' + (!!tagName ? ' ' + tagName : ''); } } + function prettyPrintEntity_(entity) { if (isElement_(entity)) { return formatElement_(entity); @@ -85,19 +86,19 @@ function prettyPrintEntity_(entity) { var str; - if (typeof entity == "function") { + if (typeof entity == 'function') { try { str = entity.toString().match(/(function [^\(]+\(\))/)[1]; } catch (e) {} - return str || "[function]"; + return str || '[function]'; } try { - str = this.JSON.stringify(entity); + str = JSON.stringify(entity); } catch (e) {} - return str || "[" + typeof entity + "]"; + return str || '[' + typeof entity + ']'; } @@ -111,56 +112,53 @@ function argsWithOptionalMsg_(args, length) { var min = length - 1; if (args.length < min) { - this.fail("expected at least " + - min + " arguments, got " + args.length); + fail('expected at least ' + min + ' arguments, got ' + args.length); } else if (args.length == length) { - copyOfArgs[0] += " "; + copyOfArgs[0] += ' '; } else { - copyOfArgs.unshift(""); + copyOfArgs.unshift(''); } return copyOfArgs; } function assertTrue(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; isBoolean_(args[1]); if (args[1] != true) { - this.fail(args[0] + 'expected true but was ' + - this.prettyPrintEntity_(args[1])); + fail(args[0] + 'expected true but was ' + prettyPrintEntity_(args[1])); } return true; -}; +} function assertFalse(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; isBoolean_(args[1]); if (args[1] != false) { - this.fail(args[0] + 'expected false but was ' + - this.prettyPrintEntity_(args[1])); + fail(args[0] + 'expected false but was ' + prettyPrintEntity_(args[1])); } return true; -}; +} function assertEquals(msg, expected, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; msg = args[0]; expected = args[1]; actual = args[2]; if (!compare_(expected, actual)) { - this.fail(msg + 'expected ' + this.prettyPrintEntity_(expected) + - ' but was ' + this.prettyPrintEntity_(actual) + ''); + fail(msg + 'expected ' + prettyPrintEntity_(expected) + ' but was ' + + prettyPrintEntity_(actual) + ''); } return true; -}; +} function compare_(expected, actual) { @@ -168,8 +166,8 @@ function compare_(expected, actual) { return true; } - if (typeof expected != "object" || - typeof actual != "object" || + if (typeof expected != 'object' || + typeof actual != 'object' || !expected || !actual) { return expected == actual; } @@ -198,7 +196,7 @@ function compare_(expected, actual) { } // Arguments object - if (actualLength == 0 && typeof actual.length == "number") { + if (actualLength == 0 && typeof actual.length == 'number') { actualLength = actual.length; for (var i = 0, l = actualLength; i < l; i++) { @@ -227,110 +225,107 @@ function compare_(expected, actual) { } catch (e) { return false; } -}; +} function assertNotEquals(msg, expected, actual) { try { assertEquals.apply(this, arguments); } catch (e) { - if (e.name == "AssertError") { + if (e.name == 'AssertError') { return true; } throw e; } - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); - this.fail(args[0] + "expected " + this.prettyPrintEntity_(args[1]) + - " not to be equal to " + this.prettyPrintEntity_(args[2])); + fail(args[0] + 'expected ' + prettyPrintEntity_(args[1]) + + ' not to be equal to ' + prettyPrintEntity_(args[2])); } function assertSame(msg, expected, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; if (!isSame_(args[2], args[1])) { - this.fail(args[0] + 'expected ' + this.prettyPrintEntity_(args[1]) + - ' but was ' + this.prettyPrintEntity_(args[2])); + fail(args[0] + 'expected ' + prettyPrintEntity_(args[1]) + ' but was ' + + prettyPrintEntity_(args[2])); } return true; -}; +} function assertNotSame(msg, expected, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; if (isSame_(args[2], args[1])) { - this.fail(args[0] + 'expected not same as ' + - this.prettyPrintEntity_(args[1]) + ' but was ' + - this.prettyPrintEntity_(args[2])); + fail(args[0] + 'expected not same as ' + prettyPrintEntity_(args[1]) + + ' but was ' + prettyPrintEntity_(args[2])); } return true; -}; +} function isSame_(expected, actual) { return actual === expected; -}; +} function assertNull(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; if (args[1] !== null) { - this.fail(args[0] + 'expected null but was ' + - this.prettyPrintEntity_(args[1])); + fail(args[0] + 'expected null but was ' + prettyPrintEntity_(args[1])); } return true; -}; +} function assertNotNull(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; if (args[1] === null) { - this.fail(args[0] + "expected not null but was null"); + fail(args[0] + 'expected not null but was null'); } return true; -}; +} function assertUndefined(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; - if (typeof args[1] != "undefined") { - this.fail(args[2] + "expected undefined but was " + - this.prettyPrintEntity_(args[1])); + if (typeof args[1] != 'undefined') { + fail(args[2] + 'expected undefined but was ' + prettyPrintEntity_(args[1])); } return true; -}; +} function assertNotUndefined(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; - if (typeof args[1] == "undefined") { - this.fail(args[0] + 'expected not undefined but was undefined'); + if (typeof args[1] == 'undefined') { + fail(args[0] + 'expected not undefined but was undefined'); } return true; -}; +} function assertNaN(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; if (!isNaN(args[1])) { - this.fail(args[0] + "expected to be NaN but was " + args[1]); + fail(args[0] + 'expected to be NaN but was ' + args[1]); } return true; @@ -338,11 +333,11 @@ function assertNaN(msg, actual) { function assertNotNaN(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; if (isNaN(args[1])) { - this.fail(args[0] + "expected not to be NaN"); + fail(args[0] + 'expected not to be NaN'); } return true; @@ -353,20 +348,20 @@ function assertException(msg, callback, error) { if (arguments.length == 1) { // assertThrows(callback) callback = msg; - msg = ""; + msg = ''; } else if (arguments.length == 2) { - if (typeof callback != "function") { + if (typeof callback != 'function') { // assertThrows(callback, type) error = callback; callback = msg; - msg = ""; + msg = ''; } else { // assertThrows(msg, callback) - msg += " "; + msg += ' '; } } else { // assertThrows(msg, callback, type) - msg += " "; + msg += ' '; } jstestdriver.assertCount++; @@ -374,53 +369,52 @@ function assertException(msg, callback, error) { try { callback(); } catch(e) { - if (e.name == "AssertError") { + if (e.name == 'AssertError') { throw e; } if (error && e.name != error) { - this.fail(msg + "expected to throw " + - error + " but threw " + e.name); + fail(msg + 'expected to throw ' + error + ' but threw ' + e.name); } return true; } - this.fail(msg + "expected to throw exception"); + fail(msg + 'expected to throw exception'); } function assertNoException(msg, callback) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; try { args[1](); } catch(e) { - fail(args[0] + "expected not to throw exception, but threw " + - e.name + " (" + e.message + ")"); + fail(args[0] + 'expected not to throw exception, but threw ' + e.name + + ' (' + e.message + ')'); } } function assertArray(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); + var args = argsWithOptionalMsg_(arguments, 2); jstestdriver.assertCount++; if (!jstestdriver.jQuery.isArray(args[1])) { - fail(args[0] + "expected to be array, but was " + - this.prettyPrintEntity_(args[1])); + fail(args[0] + 'expected to be array, but was ' + + prettyPrintEntity_(args[1])); } } function assertTypeOf(msg, expected, value) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; var actual = typeof args[2]; if (actual != args[1]) { - this.fail(args[0] + "expected to be " + args[1] + " but was " + actual); + fail(args[0] + 'expected to be ' + args[1] + ' but was ' + actual); } return true; @@ -428,44 +422,44 @@ function assertTypeOf(msg, expected, value) { function assertBoolean(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); - return assertTypeOf(args[0], "boolean", args[1]); + var args = argsWithOptionalMsg_(arguments, 2); + return assertTypeOf(args[0], 'boolean', args[1]); } function assertFunction(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); - return assertTypeOf(args[0], "function", args[1]); + var args = argsWithOptionalMsg_(arguments, 2); + return assertTypeOf(args[0], 'function', args[1]); } function assertObject(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); - return assertTypeOf(args[0], "object", args[1]); + var args = argsWithOptionalMsg_(arguments, 2); + return assertTypeOf(args[0], 'object', args[1]); } function assertNumber(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); - return assertTypeOf(args[0], "number", args[1]); + var args = argsWithOptionalMsg_(arguments, 2); + return assertTypeOf(args[0], 'number', args[1]); } function assertString(msg, actual) { - var args = this.argsWithOptionalMsg_(arguments, 2); - return assertTypeOf(args[0], "string", args[1]); + var args = argsWithOptionalMsg_(arguments, 2); + return assertTypeOf(args[0], 'string', args[1]); } function assertMatch(msg, regexp, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); - var isUndef = typeof args[2] == "undefined"; + var args = argsWithOptionalMsg_(arguments, 3); + var isUndef = typeof args[2] == 'undefined'; jstestdriver.assertCount++; var _undef; if (isUndef || !args[1].test(args[2])) { - actual = (isUndef ? _undef : this.prettyPrintEntity_(args[2])); - this.fail(args[0] + "expected " + actual + " to match " + args[1]); + actual = (isUndef ? _undef : prettyPrintEntity_(args[2])); + fail(args[0] + 'expected ' + actual + ' to match ' + args[1]); } return true; @@ -473,12 +467,12 @@ function assertMatch(msg, regexp, actual) { function assertNoMatch(msg, regexp, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; if (args[1].test(args[2])) { - this.fail(args[0] + "expected " + this.prettyPrintEntity_(args[2]) + - " not to match " + args[1]); + fail(args[0] + 'expected ' + prettyPrintEntity_(args[2]) + + ' not to match ' + args[1]); } return true; @@ -486,28 +480,27 @@ function assertNoMatch(msg, regexp, actual) { function assertTagName(msg, tagName, element) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); var actual = args[2] && args[2].tagName; if (String(actual).toUpperCase() != args[1].toUpperCase()) { - this.fail(args[0] + "expected tagName to be " + args[1] + " but was " + - actual); + fail(args[0] + 'expected tagName to be ' + args[1] + ' but was ' + actual); } return true; } function assertClassName(msg, className, element) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); var actual = args[2] && args[2].className; - var regexp = new RegExp("(^|\\s)" + args[1] + "(\\s|$)"); + var regexp = new RegExp('(^|\\s)' + args[1] + '(\\s|$)'); try { - this.assertMatch(args[0], regexp, actual); + assertMatch(args[0], regexp, actual); } catch (e) { - actual = this.prettyPrintEntity_(actual); - this.fail(args[0] + "expected class name to include " + - this.prettyPrintEntity_(args[1]) + " but was " + actual); + actual = prettyPrintEntity_(actual); + fail(args[0] + 'expected class name to include ' + + prettyPrintEntity_(args[1]) + ' but was ' + actual); } return true; @@ -515,13 +508,12 @@ function assertClassName(msg, className, element) { function assertElementId(msg, id, element) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); var actual = args[2] && args[2].id; jstestdriver.assertCount++; if (actual !== args[1]) { - this.fail(args[0] + "expected id to be " + args[1] + " but was " + - actual); + fail(args[0] + 'expected id to be ' + args[1] + ' but was ' + actual); } return true; @@ -530,18 +522,16 @@ function assertElementId(msg, id, element) { function assertInstanceOf(msg, constructor, actual) { jstestdriver.assertCount++; - var args = this.argsWithOptionalMsg_(arguments, 3); - var pretty = this.prettyPrintEntity_(args[2]); + var args = argsWithOptionalMsg_(arguments, 3); + var pretty = prettyPrintEntity_(args[2]); var expected = args[1] && args[1].name || args[1]; if (args[2] == null) { - this.fail(args[0] + "expected " + pretty + " to be instance of " + - expected); + fail(args[0] + 'expected ' + pretty + ' to be instance of ' + expected); } if (!(Object(args[2]) instanceof args[1])) { - this.fail(args[0] + "expected " + pretty + " to be instance of " + - expected); + fail(args[0] + 'expected ' + pretty + ' to be instance of ' + expected); } return true; @@ -549,17 +539,105 @@ function assertInstanceOf(msg, constructor, actual) { function assertNotInstanceOf(msg, constructor, actual) { - var args = this.argsWithOptionalMsg_(arguments, 3); + var args = argsWithOptionalMsg_(arguments, 3); jstestdriver.assertCount++; if (Object(args[2]) instanceof args[1]) { var expected = args[1] && args[1].name || args[1]; - var pretty = this.prettyPrintEntity_(args[2]); - this.fail(args[0] + "expected " + pretty + " not to be instance of " + - expected); + var pretty = prettyPrintEntity_(args[2]); + fail(args[0] + 'expected ' + pretty + ' not to be instance of ' + expected); } return true; } +/** + * Asserts that two doubles, or the elements of two arrays of doubles, + * are equal to within a positive delta. + */ +function assertEqualsDelta(msg, expected, actual, epsilon) { + var args = this.argsWithOptionalMsg_(arguments, 4); + jstestdriver.assertCount++; + msg = args[0]; + expected = args[1]; + actual = args[2]; + epsilon = args[3]; + + if (!compareDelta_(expected, actual, epsilon)) { + this.fail(msg + 'expected ' + epsilon + ' within ' + + this.prettyPrintEntity_(expected) + + ' but was ' + this.prettyPrintEntity_(actual) + ''); + } + return true; +}; + +function compareDelta_(expected, actual, epsilon) { + var compareDouble = function(e,a,d) { + return Math.abs(e - a) <= d; + } + if (expected === actual) { + return true; + } + + if (typeof expected == "number" || + typeof actual == "number" || + !expected || !actual) { + return compareDouble(expected, actual, epsilon); + } + + if (isElement_(expected) || isElement_(actual)) { + return false; + } + + var key = null; + var actualLength = 0; + var expectedLength = 0; + + try { + // If an array is expected the length of actual should be simple to + // determine. If it is not it is undefined. + if (jstestdriver.jQuery.isArray(actual)) { + actualLength = actual.length; + } else { + // In case it is an object it is a little bit more complicated to + // get the length. + for (key in actual) { + if (actual.hasOwnProperty(key)) { + ++actualLength; + } + } + } + + // Arguments object + if (actualLength == 0 && typeof actual.length == "number") { + actualLength = actual.length; + + for (var i = 0, l = actualLength; i < l; i++) { + if (!(i in actual)) { + actualLength = 0; + break; + } + } + } + + for (key in expected) { + if (expected.hasOwnProperty(key)) { + if (!compareDelta_(expected[key], actual[key], epsilon)) { + return false; + } + + ++expectedLength; + } + } + + if (expectedLength != actualLength) { + return false; + } + + return expectedLength == 0 ? expected.toString() == actual.toString() : true; + } catch (e) { + return false; + } +}; + var assert = assertTrue; diff --git a/auto_tests/lib/JsTestDriver-1.3.2.jar b/auto_tests/lib/JsTestDriver-1.3.2.jar deleted file mode 100644 index 1787c64..0000000 Binary files a/auto_tests/lib/JsTestDriver-1.3.2.jar and /dev/null differ diff --git a/auto_tests/lib/JsTestDriver-1.3.3c.jar b/auto_tests/lib/JsTestDriver-1.3.3c.jar new file mode 100644 index 0000000..39b0054 Binary files /dev/null and b/auto_tests/lib/JsTestDriver-1.3.3c.jar differ diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 0a73f16..68e53b7 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -12,7 +12,6 @@ - diff --git a/auto_tests/tests/MoreAsserts.js b/auto_tests/tests/MoreAsserts.js deleted file mode 100644 index 1380966..0000000 --- a/auto_tests/tests/MoreAsserts.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2011 Google, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -/** - * @fileoverview Additional assertions. - * - * @author konigsberg@google.com (Robert Konigsberg) - */ - -/** - * Asserts that two doubles (or two arrays of doubles) are equal - * to within a positive delta. - */ -function assertEqualsDelta(msg, expected, actual, epsilon) { - var args = this.argsWithOptionalMsg_(arguments, 4); - jstestdriver.assertCount++; - msg = args[0]; - expected = args[1]; - actual = args[2]; - epsilon = args[3]; - - if (!compareDelta_(expected, actual, epsilon)) { - this.fail(msg + 'expected ' + epsilon + ' within ' + - this.prettyPrintEntity_(expected) + - ' but was ' + this.prettyPrintEntity_(actual) + ''); - } - return true; -}; - - -function compareDelta_(expected, actual, epsilon) { - var compareDouble = function(e,a,d) { - return Math.abs(e - a) <= d; - } - if (expected === actual) { - return true; - } - - if (typeof expected == "number" || - typeof actual == "number" || - !expected || !actual) { - return compareDouble(expected, actual, epsilon); - } - - if (isElement_(expected) || isElement_(actual)) { - return false; - } - - var key = null; - var actualLength = 0; - var expectedLength = 0; - - try { - // If an array is expected the length of actual should be simple to - // determine. If it is not it is undefined. - if (jstestdriver.jQuery.isArray(actual)) { - actualLength = actual.length; - } else { - // In case it is an object it is a little bit more complicated to - // get the length. - for (key in actual) { - if (actual.hasOwnProperty(key)) { - ++actualLength; - } - } - } - - // Arguments object - if (actualLength == 0 && typeof actual.length == "number") { - actualLength = actual.length; - - for (var i = 0, l = actualLength; i < l; i++) { - if (!(i in actual)) { - actualLength = 0; - break; - } - } - } - - for (key in expected) { - if (expected.hasOwnProperty(key)) { - if (!compareDelta_(expected[key], actual[key], epsilon)) { - return false; - } - - ++expectedLength; - } - } - - if (expectedLength != actualLength) { - return false; - } - - return expectedLength == 0 ? expected.toString() == actual.toString() : true; - } catch (e) { - return false; - } -}; - diff --git a/auto_tests/tests/update_options.js b/auto_tests/tests/update_options.js index 628f615..a0bd813 100644 --- a/auto_tests/tests/update_options.js +++ b/auto_tests/tests/update_options.js @@ -19,7 +19,7 @@ UpdateOptionsTestCase.prototype.data = "X,Y1,Y2\n" + "2011-05-05,8,3\n"; UpdateOptionsTestCase.prototype.setUp = function() { - document.body.innerHTML = "
"; + document.body.innerHTML = "
"; }; UpdateOptionsTestCase.prototype.tearDown = function() { diff --git a/tests/dygraph-many-points-benchmark.html b/tests/dygraph-many-points-benchmark.html index 37c7c2b..3525e93 100644 --- a/tests/dygraph-many-points-benchmark.html +++ b/tests/dygraph-many-points-benchmark.html @@ -162,7 +162,6 @@ if (values["go"]) { updatePlot(); } -