diff options
| author | Misko Hevery | 2010-04-09 16:20:15 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-04-09 16:20:15 -0700 | 
| commit | 843bd355d25ebf2369aec79f98cb6704d38497e9 (patch) | |
| tree | 3850d13b9ad8ab6c5dd975c20cf9d849c7429ed2 /lib | |
| parent | 41a5c408c242269bf31bc0b774c7304fdf7c2f1c (diff) | |
| download | angular.js-843bd355d25ebf2369aec79f98cb6704d38497e9.tar.bz2 | |
various bug fixes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/jasmine-jstd-adapter/JasmineAdapter.js | 181 | ||||
| -rw-r--r-- | lib/jasmine/jasmine-0.10.3.js (renamed from lib/jasmine/jasmine-0.10.1.js) | 99 | ||||
| -rw-r--r-- | lib/jstestdriver/JsTestDriver.jar | bin | 3133666 -> 3133701 bytes | 
3 files changed, 171 insertions, 109 deletions
| diff --git a/lib/jasmine-jstd-adapter/JasmineAdapter.js b/lib/jasmine-jstd-adapter/JasmineAdapter.js index 83a1deed..ba54251a 100644 --- a/lib/jasmine-jstd-adapter/JasmineAdapter.js +++ b/lib/jasmine-jstd-adapter/JasmineAdapter.js @@ -1,96 +1,103 @@  /**   * @fileoverview Jasmine JsTestDriver Adapter.   * @author ibolmo@gmail.com (Olmo Maldonado) + * @author misko@hevery.com (Misko Hevery)   */  (function() { -// Suite/TestCase before and after function stacks. -var before = []; -var after = []; - -jasmine.Env.prototype.describe = (function(describe){ - -	// TODO(ibolmo): Support nested describes. -	return function(description, specDefinitions){ -		this.currentTestCase = TestCase(description); -		return describe.call(this, description, specDefinitions); -	}; - -})(jasmine.Env.prototype.describe); - - -jasmine.Env.prototype.it = (function(it){ - -	return function(desc, func){ -		var spec = it.call(this, desc, func); -		this.currentTestCase.prototype['test that it ' + desc] = func; -		return spec; -	}; - -})(jasmine.Env.prototype.it); - - -jasmine.Env.prototype.beforeEach = (function(beforeEach){ - -	// TODO(ibolmo): Support beforeEach TestCase. -	return function(beforeEachFunction) { -		beforeEach.call(this, beforeEachFunction); -		if (this.currentTestCase) { -			this.currentTestCase.prototype.setUp = beforeEachFunction; -		} else { -			before.push(beforeEachFunction); -		} -	}; - -})(jasmine.Env.prototype.beforeEach); - - -jasmine.Env.prototype.afterEach = (function(afterEach){ - -	// TODO(ibolmo): Support afterEach TestCase. -	return function(afterEachFunction) { -		afterEach.call(this, afterEachFunction); -		if (this.currentTestCase) { -			this.currentTestCase.prototype.tearDown = afterEachFunction; -		} else { -			after.push(afterEachFunction); -		} -	}; - -})(jasmine.Env.prototype.afterEach); - - -jasmine.NestedResults.prototype.addResult = (function(addResult){ - -	return function(result) { -		addResult.call(this, result); -		if (result.type != 'MessageResult' && !result.passed()) fail(result.message); -	}; - -})(jasmine.NestedResults.prototype.addResult); - - -jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration = (function(runTestConfiguration){ - -	return function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){ -		for (var i = 0, l = before.length; i < l; i++) before[i](); -		onTestRunConfigurationComplete = (function(configurationComplete){ - -			return function() { -				for (var i = 0, l = after.length; i < l; i++) after[i](); -				configurationComplete(); -			}; - -		})(onTestRunConfigurationComplete); -		runTestConfiguration.call(this, testRunConfiguration, onTestDone, onTestRunConfigurationComplete); -	}; - -})(jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration); - - -// Reset environment with overriden methods. -jasmine.currentEnv_ = null; -jasmine.getEnv(); +  function bind(_this, _function){ +    return function(){ +      return _function.call(_this); +    } +  } + +  var currentFrame = frame(null, null); + +  function frame(parent, name){ +    var caseName = (parent && parent.caseName ? parent.caseName + " " : '') + (name ? name : ''); +    var frame = { +      name: name, +      caseName: caseName, +      parent: parent, +      testCase: TestCase(caseName), +      before: [], +      after: [], +      runBefore: function(){ +        if (parent) parent.runBefore.apply(this); +        for ( var i = 0; i < frame.before.length; i++) { +          frame.before[i].apply(this); +        } +      }, +      runAfter: function(){ +        for ( var i = 0; i < frame.after.length; i++) { +          frame.after[i].apply(this); +        } +        if (parent) parent.runAfter.apply(this); +      } +    }; +    return frame; +  }; + +  jasmine.Env.prototype.describe = (function(describe){ +    return function(description){ +      currentFrame = frame(currentFrame, description); +      var val = describe.apply(this, arguments); +      currentFrame = currentFrame.parent; +      return val; +    }; + +  })(jasmine.Env.prototype.describe); + + +  jasmine.Env.prototype.it = (function(it){ +    return function(desc, itFn){ +      var self = this; +      var spec = it.apply(this, arguments); +      var currentSpec = this.currentSpec; +      var frame = this.jstdFrame = currentFrame; +      this.jstdFrame.testCase.prototype['test that it ' + desc] = function(){ +        frame.runBefore.apply(currentSpec); +        try { +          itFn.apply(currentSpec); +        } finally { +          frame.runAfter.apply(currentSpec); +        } +      }; +      return spec; +    }; + +  })(jasmine.Env.prototype.it); + + +  jasmine.Env.prototype.beforeEach = (function(beforeEach){ +    return function(beforeEachFunction) { +      beforeEach.apply(this, arguments); +      currentFrame.before.push(beforeEachFunction); +    }; + +  })(jasmine.Env.prototype.beforeEach); + + +  jasmine.Env.prototype.afterEach = (function(afterEach){ +    return function(afterEachFunction) { +      afterEach.apply(this, arguments); +      currentFrame.after.push(afterEachFunction); +    }; + +  })(jasmine.Env.prototype.afterEach); + + +  jasmine.NestedResults.prototype.addResult = (function(addResult){ +    return function(result) { +      addResult.call(this, result); +      if (result.type != 'MessageResult' && !result.passed()) fail(result.message); +    }; + +  })(jasmine.NestedResults.prototype.addResult); + +  // Reset environment with overriden methods. +  jasmine.currentEnv_ = null; +  jasmine.getEnv();  })(); diff --git a/lib/jasmine/jasmine-0.10.1.js b/lib/jasmine/jasmine-0.10.3.js index f9bd7d6f..f309493f 100644 --- a/lib/jasmine/jasmine-0.10.1.js +++ b/lib/jasmine/jasmine-0.10.3.js @@ -13,7 +13,7 @@ jasmine.unimplementedMethod_ = function() {  };  /** - * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just + * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just   * a plain old variable and may be redefined by somebody else.   *   * @private @@ -89,7 +89,38 @@ jasmine.getEnv = function() {   * @returns {Boolean}   */  jasmine.isArray_ = function(value) { -  return Object.prototype.toString.apply(value) === '[object Array]'; +  return jasmine.isA_("Array", value);   +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isString_ = function(value) { +  return jasmine.isA_("String", value); +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isNumber_ = function(value) { +  return jasmine.isA_("Number", value); +}; + +/** + * @ignore + * @private + * @param {String} typeName + * @param value + * @returns {Boolean} + */ +jasmine.isA_ = function(typeName, value) { +  return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';  };  /** @@ -527,6 +558,7 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {   *   * @param {String} url path to the file to include   * @param {Boolean} opt_global + * @deprecated We suggest you use a different method of including JS source files. <code>jasmine.include</code> will be removed soon.   */  jasmine.include = function(url, opt_global) {    if (opt_global) { @@ -660,6 +692,18 @@ jasmine.Env.prototype.version = function () {  };  /** + * @returns string containing jasmine version build info, if set. + */ +jasmine.Env.prototype.versionString = function() { +  if (jasmine.version_) { +    var version = this.version(); +    return version.major + "." + version.minor + "." + version.build + " revision " + version.revision; +  } else { +    return "version unknown"; +  } +}; + +/**   * @returns a sequential integer starting at 0   */  jasmine.Env.prototype.nextSpecId = function () { @@ -794,6 +838,12 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {    mismatchKeys = mismatchKeys || [];    mismatchValues = mismatchValues || []; +  for (var i = 0; i < this.equalityTesters_.length; i++) { +    var equalityTester = this.equalityTesters_[i]; +    var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); +    if (result !== jasmine.undefined) return result; +  } +    if (a === b) return true;    if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { @@ -816,14 +866,16 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {      return b.matches(a);    } -  if (typeof a === "object" && typeof b === "object") { -    return this.compareObjects_(a, b, mismatchKeys, mismatchValues); +  if (jasmine.isString_(a) && jasmine.isString_(b)) { +    return (a == b);    } -  for (var i = 0; i < this.equalityTesters_.length; i++) { -    var equalityTester = this.equalityTesters_[i]; -    var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); -    if (result !== jasmine.undefined) return result; +  if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { +    return (a == b); +  } + +  if (typeof a === "object" && typeof b === "object") { +    return this.compareObjects_(a, b, mismatchKeys, mismatchValues);    }    //Straight check @@ -1009,11 +1061,13 @@ jasmine.Matchers = function(env, actual, spec, opt_isNot) {    this.reportWasCalled_ = false;  }; +// todo: @deprecated as of Jasmine 0.11, remove soon [xw]  jasmine.Matchers.pp = function(str) { -  return jasmine.util.htmlEscape(jasmine.pp(str)); +  throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); +  this.report();  }; -/** @deprecated */ +/** @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. */  jasmine.Matchers.prototype.report = function(result, failing_message, details) {    // todo: report a deprecation warning [xw] @@ -1180,7 +1234,7 @@ jasmine.Matchers.prototype.wasCalled = function() {    }    if (!jasmine.isSpy(this.actual)) { -    throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');    }    this.message = function() { @@ -1199,7 +1253,7 @@ jasmine.Matchers.prototype.wasNotCalled = function() {    }    if (!jasmine.isSpy(this.actual)) { -    throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');    }    this.message = function() { @@ -1218,7 +1272,7 @@ jasmine.Matchers.prototype.wasNotCalled = function() {  jasmine.Matchers.prototype.wasCalledWith = function() {    var expectedArgs = jasmine.util.argsToArray(arguments);    if (!jasmine.isSpy(this.actual)) { -    throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');    }    this.message = function() {      if (this.actual.callCount == 0) { @@ -1234,7 +1288,7 @@ jasmine.Matchers.prototype.wasCalledWith = function() {  jasmine.Matchers.prototype.wasNotCalledWith = function() {    var expectedArgs = jasmine.util.argsToArray(arguments);    if (!jasmine.isSpy(this.actual)) { -    throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');    }    this.message = function() { @@ -1882,8 +1936,7 @@ jasmine.Spec.prototype.finish = function(onComplete) {    }  }; -jasmine.Spec.prototype.after = function(doAfter, test) { - +jasmine.Spec.prototype.after = function(doAfter) {    if (this.queue.isRunning()) {      this.queue.add(new jasmine.Block(this.env, doAfter, this));    } else { @@ -1911,23 +1964,25 @@ jasmine.Spec.prototype.execute = function(onComplete) {  jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {    var runner = this.env.currentRunner(); +  var i; +    for (var suite = this.suite; suite; suite = suite.parentSuite) { -    for (var i = 0; i < suite.before_.length; i++) { +    for (i = 0; i < suite.before_.length; i++) {        this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));      }    } -  for (var i = 0; i < runner.before_.length; i++) { +  for (i = 0; i < runner.before_.length; i++) {      this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));    }    for (i = 0; i < this.afterCallbacks.length; i++) {      this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));    }    for (suite = this.suite; suite; suite = suite.parentSuite) { -    for (var i = 0; i < suite.after_.length; i++) { +    for (i = 0; i < suite.after_.length; i++) {        this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));      }    } -  for (var i = 0; i < runner.after_.length; i++) { +  for (i = 0; i < runner.after_.length; i++) {      this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));    }  }; @@ -2271,6 +2326,6 @@ window.clearInterval = function(timeoutKey) {  jasmine.version_= {    "major": 0,    "minor": 10, -  "build": 1, -  "revision": 1267503060 +  "build": 3, +  "revision": 1270162784    }; diff --git a/lib/jstestdriver/JsTestDriver.jar b/lib/jstestdriver/JsTestDriver.jarBinary files differ index ead31593..00482eda 100644 --- a/lib/jstestdriver/JsTestDriver.jar +++ b/lib/jstestdriver/JsTestDriver.jar | 
