• Home
  • Raw
  • Download

Lines Matching refs:self

31   def createTestAssertion(self, checkerString):  argument
36 def tryMatch(self, checkerString, c1String, varState={}): argument
37 return MatchLines(self.createTestAssertion(checkerString),
41 def assertMatches(self, checkerString, c1String, varState={}): argument
42 self.assertIsNotNone(self.tryMatch(checkerString, c1String, varState))
44 def assertDoesNotMatch(self, checkerString, c1String, varState={}): argument
45 self.assertIsNone(self.tryMatch(checkerString, c1String, varState))
47 def test_TextAndWhitespace(self): argument
48 self.assertMatches("foo", "foo")
49 self.assertMatches("foo", " foo ")
50 self.assertMatches("foo", "foo bar")
51 self.assertDoesNotMatch("foo", "XfooX")
52 self.assertDoesNotMatch("foo", "zoo")
54 self.assertMatches("foo bar", "foo bar")
55 self.assertMatches("foo bar", "abc foo bar def")
56 self.assertMatches("foo bar", "foo foo bar bar")
58 self.assertMatches("foo bar", "foo X bar")
59 self.assertDoesNotMatch("foo bar", "foo Xbar")
61 def test_Pattern(self): argument
62 self.assertMatches("foo{{A|B}}bar", "fooAbar")
63 self.assertMatches("foo{{A|B}}bar", "fooBbar")
64 self.assertDoesNotMatch("foo{{A|B}}bar", "fooCbar")
66 def test_VariableReference(self): argument
67 self.assertMatches("foo<<X>>bar", "foobar", {"X": ""})
68 self.assertMatches("foo<<X>>bar", "fooAbar", {"X": "A"})
69 self.assertMatches("foo<<X>>bar", "fooBbar", {"X": "B"})
70 self.assertDoesNotMatch("foo<<X>>bar", "foobar", {"X": "A"})
71 self.assertDoesNotMatch("foo<<X>>bar", "foo bar", {"X": "A"})
72 with self.assertRaises(CheckerException):
73 self.tryMatch("foo<<X>>bar", "foobar", {})
75 def test_VariableDefinition(self): argument
76 self.assertMatches("foo<<X:A|B>>bar", "fooAbar")
77 self.assertMatches("foo<<X:A|B>>bar", "fooBbar")
78 self.assertDoesNotMatch("foo<<X:A|B>>bar", "fooCbar")
80 env = self.tryMatch("foo<<X:A.*B>>bar", "fooABbar", {})
81 self.assertEqual(env, {"X": "AB"})
82 env = self.tryMatch("foo<<X:A.*B>>bar", "fooAxxBbar", {})
83 self.assertEqual(env, {"X": "AxxB"})
85 self.assertMatches("foo<<X:A|B>>bar<<X>>baz", "fooAbarAbaz")
86 self.assertMatches("foo<<X:A|B>>bar<<X>>baz", "fooBbarBbaz")
87 self.assertDoesNotMatch("foo<<X:A|B>>bar<<X>>baz", "fooAbarBbaz")
89 def test_NoVariableRedefinition(self): argument
90 with self.assertRaises(CheckerException):
91 self.tryMatch("<<X:...>><<X>><<X:...>><<X>>", "foofoobarbar")
93 def test_EnvNotChangedOnPartialMatch(self): argument
95 self.assertDoesNotMatch("<<X:A>>bar", "Abaz", env)
96 self.assertFalse("X" in env.keys())
98 def test_VariableContentEscaped(self): argument
99 self.assertMatches("<<X:..>>foo<<X>>", ".*foo.*")
100 self.assertDoesNotMatch("<<X:..>>foo<<X>>", ".*fooAAAA")
105 def assertMatches(self, checkerString, c1String): argument
129 def assertDoesNotMatch(self, checkerString, c1String): argument
130 with self.assertRaises(MatchFailedException):
131 self.assertMatches(checkerString, c1String)
133 def test_Text(self): argument
134 self.assertMatches("/// CHECK: foo bar", "foo bar")
135 self.assertDoesNotMatch("/// CHECK: foo bar", "abc def")
137 def test_Pattern(self): argument
138 self.assertMatches("/// CHECK: abc {{de.}}", "abc de#")
139 self.assertDoesNotMatch("/// CHECK: abc {{de.}}", "abc d#f")
141 def test_Variables(self): argument
142 self.assertMatches(
151 self.assertMatches(
162 self.assertDoesNotMatch(
172 def test_WholeWordMustMatch(self): argument
173 self.assertMatches("/// CHECK: b{{.}}r", "abc bar def")
174 self.assertDoesNotMatch("/// CHECK: b{{.}}r", "abc Xbar def")
175 self.assertDoesNotMatch("/// CHECK: b{{.}}r", "abc barX def")
176 self.assertDoesNotMatch("/// CHECK: b{{.}}r", "abc b r def")
178 def test_InOrderAssertions(self): argument
179 self.assertMatches(
188 self.assertDoesNotMatch(
198 def test_NextLineAssertions(self): argument
199 self.assertMatches(
212 self.assertMatches(
224 self.assertDoesNotMatch(
235 self.assertDoesNotMatch(
246 def test_DagAssertions(self): argument
247 self.assertMatches(
256 self.assertMatches(
266 def test_DagAssertionsScope(self): argument
267 self.assertMatches(
280 self.assertDoesNotMatch(
293 self.assertDoesNotMatch(
307 def test_NotAssertions(self): argument
308 self.assertMatches(
316 self.assertDoesNotMatch(
324 self.assertDoesNotMatch(
334 def test_NotAssertionsScope(self): argument
335 self.assertMatches(
345 self.assertMatches(
356 self.assertDoesNotMatch(
368 def test_LineOnlyMatchesOnce(self): argument
369 self.assertMatches(
379 self.assertDoesNotMatch(
390 def test_EvalAssertions(self): argument
391 self.assertMatches("/// CHECK-EVAL: True", "foo")
392 self.assertDoesNotMatch("/// CHECK-EVAL: False", "foo")
394 self.assertMatches("/// CHECK-EVAL: 1 + 2 == 3", "foo")
395 self.assertDoesNotMatch("/// CHECK-EVAL: 1 + 2 == 4", "foo")
401 self.assertMatches(twoVarTestCase, "42 41");
402 self.assertDoesNotMatch(twoVarTestCase, "42 43")