# lib/goog/labs/testing/matcher.js

    1// Copyright 2012 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7//      http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.1415/**16 * @fileoverview Provides the base Matcher interface. User code should use the17 * matchers through assertThat statements and not directly.18 */192021goog.provide('goog.labs.testing.Matcher');22232425/**26 * A matcher object to be used in assertThat statements.27 * @interface28 */29goog.labs.testing.Matcher = function() {};303132/**33 * Determines whether a value matches the constraints of the match.34 *35 * @param {*} value The object to match.36 * @return {boolean} Whether the input value matches this matcher.37 */38goog.labs.testing.Matcher.prototype.matches = function(value) {};394041/**42 * Describes why the matcher failed.43 *44 * @param {*} value The value that didn't match.45 * @param {string=} opt_description A partial description to which the reason46 *     will be appended.47 *48 * @return {string} Description of why the matcher failed.49 */50goog.labs.testing.Matcher.prototype.describe =51    function(value, opt_description) {};525354/**55 * Generates a Matcher from the ‘matches’ and ‘describe’ functions passed in.56 *57 * @param {!Function} matchesFunction The ‘matches’ function.58 * @param {Function=} opt_describeFunction The ‘describe’ function.59 * @return {!Function} The custom matcher.60 */61goog.labs.testing.Matcher.makeMatcher =62    function(matchesFunction, opt_describeFunction) {6364  /**65   * @constructor66   * @implements {goog.labs.testing.Matcher}67   * @final68   */69  var matcherConstructor = function() {};7071  /** @override */72  matcherConstructor.prototype.matches = matchesFunction;7374  if (opt_describeFunction) {75    /** @override */76    matcherConstructor.prototype.describe = opt_describeFunction;77  }7879  return matcherConstructor;80};