123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- goog.provide('goog.labs.testing.AllOfMatcher');
- goog.provide('goog.labs.testing.AnyOfMatcher');
- goog.provide('goog.labs.testing.IsNotMatcher');
- goog.require('goog.array');
- goog.require('goog.labs.testing.Matcher');
- goog.labs.testing.AllOfMatcher = function(matchers) {
-
- this.matchers_ = matchers;
- };
- goog.labs.testing.AllOfMatcher.prototype.matches = function(actualValue) {
- return goog.array.every(this.matchers_, function(matcher) {
- return matcher.matches(actualValue);
- });
- };
- goog.labs.testing.AllOfMatcher.prototype.describe = function(actualValue) {
-
- var errorString = '';
- goog.array.forEach(this.matchers_, function(matcher) {
- if (!matcher.matches(actualValue)) {
- errorString += matcher.describe(actualValue) + '\n';
- }
- });
- return errorString;
- };
- goog.labs.testing.AnyOfMatcher = function(matchers) {
-
- this.matchers_ = matchers;
- };
- goog.labs.testing.AnyOfMatcher.prototype.matches = function(actualValue) {
- return goog.array.some(this.matchers_, function(matcher) {
- return matcher.matches(actualValue);
- });
- };
- goog.labs.testing.AnyOfMatcher.prototype.describe = function(actualValue) {
-
- var errorString = '';
- goog.array.forEach(this.matchers_, function(matcher) {
- if (!matcher.matches(actualValue)) {
- errorString += matcher.describe(actualValue) + '\n';
- }
- });
- return errorString;
- };
- goog.labs.testing.IsNotMatcher = function(matcher) {
-
- this.matcher_ = matcher;
- };
- goog.labs.testing.IsNotMatcher.prototype.matches = function(actualValue) {
- return !this.matcher_.matches(actualValue);
- };
- goog.labs.testing.IsNotMatcher.prototype.describe = function(actualValue) {
- return 'The following is false: ' + this.matcher_.describe(actualValue);
- };
- function allOf(var_args) {
- var matchers = goog.array.toArray(arguments);
- return new goog.labs.testing.AllOfMatcher(matchers);
- }
- function anyOf(var_args) {
- var matchers = goog.array.toArray(arguments);
- return new goog.labs.testing.AnyOfMatcher(matchers);
- }
- function isNot(matcher) {
- return new goog.labs.testing.IsNotMatcher(matcher);
- }
|