123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- goog.provide('goog.labs.testing.AnyNumberMatcher');
- goog.provide('goog.labs.testing.CloseToMatcher');
- goog.provide('goog.labs.testing.EqualToMatcher');
- goog.provide('goog.labs.testing.GreaterThanEqualToMatcher');
- goog.provide('goog.labs.testing.GreaterThanMatcher');
- goog.provide('goog.labs.testing.LessThanEqualToMatcher');
- goog.provide('goog.labs.testing.LessThanMatcher');
- goog.require('goog.asserts');
- goog.require('goog.labs.testing.Matcher');
- goog.labs.testing.AnyNumberMatcher = function() {};
- goog.labs.testing.AnyNumberMatcher.prototype.matches = function(actualValue) {
- return goog.isNumber(actualValue);
- };
- goog.labs.testing.AnyNumberMatcher.prototype.describe = function(actualValue) {
- return '<' + actualValue + '> is not a number';
- };
- goog.labs.testing.GreaterThanMatcher = function(value) {
-
- this.value_ = value;
- };
- goog.labs.testing.GreaterThanMatcher.prototype.matches = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue > this.value_;
- };
- goog.labs.testing.GreaterThanMatcher.prototype.describe = function(
- actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not greater than ' + this.value_;
- };
- goog.labs.testing.LessThanMatcher = function(value) {
-
- this.value_ = value;
- };
- goog.labs.testing.LessThanMatcher.prototype.matches = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue < this.value_;
- };
- goog.labs.testing.LessThanMatcher.prototype.describe = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not less than ' + this.value_;
- };
- goog.labs.testing.GreaterThanEqualToMatcher = function(value) {
-
- this.value_ = value;
- };
- goog.labs.testing.GreaterThanEqualToMatcher.prototype.matches = function(
- actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue >= this.value_;
- };
- goog.labs.testing.GreaterThanEqualToMatcher.prototype.describe = function(
- actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not greater than equal to ' + this.value_;
- };
- goog.labs.testing.LessThanEqualToMatcher = function(value) {
-
- this.value_ = value;
- };
- goog.labs.testing.LessThanEqualToMatcher.prototype.matches = function(
- actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue <= this.value_;
- };
- goog.labs.testing.LessThanEqualToMatcher.prototype.describe = function(
- actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not less than equal to ' + this.value_;
- };
- goog.labs.testing.EqualToMatcher = function(value) {
-
- this.value_ = value;
- };
- goog.labs.testing.EqualToMatcher.prototype.matches = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue === this.value_;
- };
- goog.labs.testing.EqualToMatcher.prototype.describe = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not equal to ' + this.value_;
- };
- goog.labs.testing.CloseToMatcher = function(value, range) {
-
- this.value_ = value;
-
- this.range_ = range;
- };
- goog.labs.testing.CloseToMatcher.prototype.matches = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return Math.abs(this.value_ - actualValue) < this.range_;
- };
- goog.labs.testing.CloseToMatcher.prototype.describe = function(actualValue) {
- goog.asserts.assertNumber(actualValue);
- return actualValue + ' is not close to(' + this.range_ + ') ' + this.value_;
- };
- function anyNumber() {
- return new goog.labs.testing.AnyNumberMatcher();
- }
- function greaterThan(value) {
- return new goog.labs.testing.GreaterThanMatcher(value);
- }
- function greaterThanEqualTo(value) {
- return new goog.labs.testing.GreaterThanEqualToMatcher(value);
- }
- function lessThan(value) {
- return new goog.labs.testing.LessThanMatcher(value);
- }
- function lessThanEqualTo(value) {
- return new goog.labs.testing.LessThanEqualToMatcher(value);
- }
- function equalTo(value) {
- return new goog.labs.testing.EqualToMatcher(value);
- }
- function closeTo(value, range) {
- return new goog.labs.testing.CloseToMatcher(value, range);
- }
|