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/jasmine | |
| parent | 41a5c408c242269bf31bc0b774c7304fdf7c2f1c (diff) | |
| download | angular.js-843bd355d25ebf2369aec79f98cb6704d38497e9.tar.bz2 | |
various bug fixes
Diffstat (limited to 'lib/jasmine')
| -rw-r--r-- | lib/jasmine/jasmine-0.10.3.js (renamed from lib/jasmine/jasmine-0.10.1.js) | 99 | 
1 files changed, 77 insertions, 22 deletions
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    };  | 
