Exemple #1
0
  def handleNotQueue(self, scope):
    """ Verifies that none of the given NOT statements matches a line inside
        the given `scope` of `c1Pass` lines.

    Raises MatchFailedException if a statement matches a line in the scope.
    """
    for statement in self.notQueue:
      assert statement.variant == TestStatement.Variant.Not
      for i in range(scope.start, scope.end):
        if MatchLines(statement, self.c1Pass.body[i], self.variables) is not None:
          raise MatchFailedException(statement, i, self.variables)
    self.notQueue = []
Exemple #2
0
def testNotGroup(statements, c1Pass, scope, variables):
    """ Verifies that none of the given NOT statements matches a line inside
      the given `scope` of `c1Pass` lines.

  Raises MatchFailedException if an statement matches a line in the scope.
  """
    for i in range(scope.start, scope.end):
        line = c1Pass.body[i]
        for statement in statements:
            assert statement.variant == TestStatement.Variant.Not
            if MatchLines(statement, line, variables) is not None:
                raise MatchFailedException(statement, i, variables)
Exemple #3
0
def testNotGroup(assertions, c1Pass, scope, variables):
    """ Verifies that none of the given NOT assertions matches a line inside
      the given `scope` of `c1Pass` lines.

  Raises MatchFailedException if an assertion matches a line in the scope.
  """
    for i in range(scope.start, scope.end):
        line = c1Pass.body[i]
        for assertion in assertions:
            assert assertion.variant == TestAssertion.Variant.Not
            if MatchLines(assertion, line, variables) is not None:
                raise MatchFailedException(assertion, i)
Exemple #4
0
def findMatchingLine(statement, c1Pass, scope, variables, excludeLines=[]):
  """ Finds the first line in `c1Pass` which matches `statement`.

  Scan only lines numbered between `scope.start` and `scope.end` and not on the
  `excludeLines` list.

  Returns the index of the `c1Pass` line matching the statement and variables
  values after the match.

  Raises MatchFailedException if no such `c1Pass` line can be found.
  """
  for i in range(scope.start, scope.end):
    if i in excludeLines: continue
    newVariables = MatchLines(statement, c1Pass.body[i], variables)
    if newVariables is not None:
      return MatchInfo(MatchScope(i, i), newVariables)
  raise MatchFailedException(statement, scope.start, variables)
Exemple #5
0
 def tryMatch(self, checkerString, c1String, varState={}):
     return MatchLines(self.createTestStatement(checkerString),
                       ToUnicode(c1String), ImmutableDict(varState))