Expect that `$actual` match the `$expected` pattern.

@param  mixed   $actual   The actual value.
@param  mixed   $expected The expected regexp pattern or the closure to use
for the matching.
@return boolean
174356
public static function match($actual, $expected)
    {
        if (is_callable($expected)) {
            return $expected($actual);
        }
        $actual = static::_nl($actual);
        return !!preg_match($expected, $actual);
    }
838766
public static function provideDiff($expected, $actual, $message = null)
    {
        return 'Mismatch: (- expected, + actual)' . PHP_EOL . PHP_EOL .
            '- ' . $expected . PHP_EOL .
            '+ ' . $actual . PHP_EOL . PHP_EOL .
            'Info: ' . $message;
    }
1056154
public function doMatch($actual)
    {
        $this->type = gettype($actual);

        return $this->expected === $this->type;
    }
1344591
public function notTypeOf($actual, $expected, $message = '')
    {
        $this->assertion->setActual($actual);

        return $this->assertion->to->not->be->a($expected, $message);
    }
967495
def evaluate(actual, expected)
      expected = %r[#{Regexp.escape(expected)}] if expected.kind_of?(String)
      if actual.to_s =~ expected
        pass(new_message.matches(expected))
      else
        fail(expected_message(expected).to_match(actual))
      end
    end
599576
protected function compareMail($actualMail, $expectedMail)
    {
        // Make sure there is the same number of actual and expected.
        $expectedCount = count($expectedMail);
        $this->assertMailCount($actualMail, $expectedCount);

        // For each row of expected mail, check the corresponding actual mail.
        // Make the comparison insensitive to the order mails were sent.
        $actualMail = $this->sortMail($actualMail);
        $expectedMail = $this->sortMail($expectedMail);
        foreach ($expectedMail as $index => $expectedMailItem) {
            // For each column of the expected, check the field of the actual mail.
            foreach ($expectedMailItem as $fieldName => $fieldValue) {
                $expectedField = [$fieldName => $fieldValue];
                $match = $this->matchesMail($actualMail[$index], $expectedField);
                if (!$match) {
                    throw new \Exception(sprintf("The #%s mail did not have '%s' in its %s field. It had:\n'%s'", $index, $fieldValue, $fieldName, mb_strimwidth($actualMail[$index][$fieldName], 0, 30, "...")));
                }
            }
        }
    }
689429
private function matchVersion($actual, array $preset)
    {
        if (!$actual || !array_key_exists('version', $preset)) {
            return false;
        }

        return Semver::satisfies($actual, $preset['version']);
    }
1067343
protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
1060391
def match_value?(actual, expected)
      case expected
      when Symbol
        if Parser::AST::Node === actual
          actual.to_source == ":#{expected}"
        else
          actual.to_sym == expected
        end
      when String
        if Parser::AST::Node === actual
          actual.to_source == expected ||
            (actual.to_source[0] == ':' && actual.to_source[1..-1] == expected) ||
            actual.to_source[1...-1] == expected
        else
          actual.to_s == expected
        end
      when Regexp
        if Parser::AST::Node === actual
          actual.to_source =~ Regexp.new(expected.to_s, Regexp::MULTILINE)
        else
          actual.to_s =~ Regexp.new(expected.to_s, Regexp::MULTILINE)
        end
      when Array
        return false unless expected.length == actual.length
        actual.zip(expected).all? { |a, e| match_value?(a, e) }
      when NilClass
        actual.nil?
      when Numeric
        if Parser::AST::Node === actual
          actual.children[0] == expected
        else
          actual == expected
        end
      when TrueClass
        :true == actual.type
      when FalseClass
        :false == actual.type
      when Parser::AST::Node
        actual == expected
      else
        raise Synvert::Core::MethodNotSupported.new "#{expected.class} is not handled for match_value?"
      end
    end
751183
protected function doMatch($actual)
    {
        $actual = $this->getArrayValue($actual);
        if ($this->assertion->flag('contain')) {
            $this->verb = 'contain';

            return $this->matchInclusion($actual);
        }
        $keys = array_keys($actual);

        return $keys == $this->expected;
    }
1355565
public function waitsFor($actual, $timeout = 0)
    {
        $timeout = $timeout ?: $this->timeout();
        $closure = $actual instanceof Closure ? $actual : function () use ($actual) {
            return $actual;
        };
        $spec = new static(['closure' => $closure]);

        return $this->expect($spec, $timeout);
    }
578135
public static function actual($actual)
    {
        if (is_string($actual)) {
            return strlen($actual);
        } elseif (is_array($actual) || $actual instanceof Countable) {
            return count($actual);
        }
    }
962392
static function assertEqualIterable(iterable $expected, $actual, string $message = ''): void
    {
        static::assertThat($actual, static::equalIterable($expected), $message);
    }
653620
public static function match($actual, $expected = null)
    {
        $args = func_get_args();
        $actual = array_shift($args);
        return new static($actual, $args);
    }
261697
private static function expect($expected, $token)
    {
        if (!in_array($token['type'], $expected)) {
            if (count($expected) === 1) {
                $expectedStr = self::tokenName($expected[0]);
            } else {
                $last = array_pop($expected);
                $expectedStr = 'one of ' . implode(', ', array_map(['self', 'tokenName'], $expected)) . ' or ' . self::tokenName($last);
            }
            $actualStr = self::tokenName($token['type']);
            if ($token['match']) {
                $actualStr .= " ('" . addslashes($token['match']) . "')";
            }
            $actualStr .= ' <<< ' . Json::dump($token) . ' >>> ';
            throw new PermissionParserException("Parser error: expected $expectedStr, but found $actualStr");
        }
    }
816974
public static function match($actual, $expected = null)
    {
        $a = static::actual($actual);
        static::_buildDescription($a, $expected);

        return $a === $expected;
    }
599369
function assertMatch(actual, expected, message) {
  if (isRegExp(expected))
    assert(expected.test(actual), message || `Expected "${actual}" to match "${expected}"`);
  else if (typeof expected === 'function')
    assert(expected(actual), message);
  else
    assert.deepEqual(actual, expected, message);
}