test.py revision c4de9436bbfe3a9c9adf48085b9344ad9a37c14b
12c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# Copyright (C) 2014 The Android Open Source Project 22c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# 32c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# Licensed under the Apache License, Version 2.0 (the "License"); 42c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# you may not use this file except in compliance with the License. 52c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# You may obtain a copy of the License at 62c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# 72c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# http://www.apache.org/licenses/LICENSE-2.0 82c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# 92c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# Unless required by applicable law or agreed to in writing, software 102c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# distributed under the License is distributed on an "AS IS" BASIS, 112c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# See the License for the specific language governing permissions and 132c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil# limitations under the License. 142c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 15c4de9436bbfe3a9c9adf48085b9344ad9a37c14bDavid Brazdilfrom common.immutables import ImmutableDict 162c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom common.testing import ToUnicode 172c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom file_format.c1visualizer.parser import ParseC1visualizerStream 182c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom file_format.c1visualizer.struct import C1visualizerFile, C1visualizerPass 192c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom file_format.checker.parser import ParseCheckerStream, ParseCheckerAssertion 202c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom file_format.checker.struct import CheckerFile, TestCase, TestAssertion, RegexExpression 212c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom match.file import MatchFiles 222c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilfrom match.line import MatchLines 232c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 242c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilimport io 252c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilimport unittest 262c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 272c27f2ccf316aebf96cf365d33d2834a8206444dDavid BrazdilCheckerException = SystemExit 282c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 292c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilclass MatchLines_Test(unittest.TestCase): 302c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 312c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def createTestAssertion(self, checkerString): 322c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil checkerFile = CheckerFile("<checker-file>") 332c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil testCase = TestCase(checkerFile, "TestMethod TestPass", 0) 342c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil return ParseCheckerAssertion(testCase, checkerString, TestAssertion.Variant.InOrder, 0) 352c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 362c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def tryMatch(self, checkerString, c1String, varState={}): 37c4de9436bbfe3a9c9adf48085b9344ad9a37c14bDavid Brazdil return MatchLines(self.createTestAssertion(checkerString), 38c4de9436bbfe3a9c9adf48085b9344ad9a37c14bDavid Brazdil ToUnicode(c1String), 39c4de9436bbfe3a9c9adf48085b9344ad9a37c14bDavid Brazdil ImmutableDict(varState)) 402c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 412c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def matches(self, checkerString, c1String, varState={}): 422c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil return self.tryMatch(checkerString, c1String, varState) is not None 432c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 442c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_TextAndWhitespace(self): 452c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo", "foo")) 462c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo", " foo ")) 472c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo", "foo bar")) 482c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("foo", "XfooX")) 492c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("foo", "zoo")) 502c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 512c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo bar", "foo bar")) 522c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo bar", "abc foo bar def")) 532c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo bar", "foo foo bar bar")) 542c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 552c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo bar", "foo X bar")) 562c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("foo bar", "foo Xbar")) 572c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 582c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_Pattern(self): 592c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo{{A|B}}bar", "fooAbar")) 602c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches("foo{{A|B}}bar", "fooBbar")) 612c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("foo{{A|B}}bar", "fooCbar")) 622c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 632c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_VariableReference(self): 64c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X>>bar", "foobar", {"X": ""})) 65c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X>>bar", "fooAbar", {"X": "A"})) 66c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X>>bar", "fooBbar", {"X": "B"})) 67c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("foo<<X>>bar", "foobar", {"X": "A"})) 68c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("foo<<X>>bar", "foo bar", {"X": "A"})) 692c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil with self.assertRaises(CheckerException): 70c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X>>bar", "foobar", {})) 712c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 722c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_VariableDefinition(self): 73c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X:A|B>>bar", "fooAbar")) 74c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X:A|B>>bar", "fooBbar")) 75c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("foo<<X:A|B>>bar", "fooCbar")) 762c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 77c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil env = self.tryMatch("foo<<X:A.*B>>bar", "fooABbar", {}) 782c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertEqual(env, {"X": "AB"}) 79c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil env = self.tryMatch("foo<<X:A.*B>>bar", "fooAxxBbar", {}) 802c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertEqual(env, {"X": "AxxB"}) 812c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 82c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X:A|B>>bar<<X>>baz", "fooAbarAbaz")) 83c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("foo<<X:A|B>>bar<<X>>baz", "fooBbarBbaz")) 84c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("foo<<X:A|B>>bar<<X>>baz", "fooAbarBbaz")) 852c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 862c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_NoVariableRedefinition(self): 872c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil with self.assertRaises(CheckerException): 88c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.matches("<<X:...>><<X>><<X:...>><<X>>", "foofoobarbar") 892c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 902c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_EnvNotChangedOnPartialMatch(self): 912c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil env = {"Y": "foo"} 92c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("<<X:A>>bar", "Abaz", env)) 932c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse("X" in env.keys()) 942c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 952c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_VariableContentEscaped(self): 96c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertTrue(self.matches("<<X:..>>foo<<X>>", ".*foo.*")) 97c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil self.assertFalse(self.matches("<<X:..>>foo<<X>>", ".*fooAAAA")) 982c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 992c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1002c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdilclass MatchFiles_Test(unittest.TestCase): 1012c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1022c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def matches(self, checkerString, c1String): 1032c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil checkerString = \ 1042c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1052c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-START: MyMethod MyPass 1062c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ + checkerString 1072c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil c1String = \ 1082c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1092c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil begin_compilation 1102c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil name "MyMethod" 1112c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil method "MyMethod" 1122c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil date 1234 1132c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil end_compilation 1142c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil begin_cfg 1152c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil name "MyPass" 1162c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ + c1String + \ 1172c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1182c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil end_cfg 1192c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1202c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil checkerFile = ParseCheckerStream("<test-file>", "CHECK", io.StringIO(ToUnicode(checkerString))) 1212c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil c1File = ParseC1visualizerStream("<c1-file>", io.StringIO(ToUnicode(c1String))) 1222c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil try: 1232c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil MatchFiles(checkerFile, c1File) 1242c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil return True 1252c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil except CheckerException: 1262c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil return False 1272c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1282c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_Text(self): 1292c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( "// CHECK: foo bar", "foo bar")) 1302c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("// CHECK: foo bar", "abc def")) 1312c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1322c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_Pattern(self): 1332c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( "// CHECK: abc {{de.}}", "abc de#")) 1342c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches("// CHECK: abc {{de.}}", "abc d#f")) 1352c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1362c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_Variables(self): 1372c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 1382c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 139c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: foo<<X:.>>bar 140c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: abc<<X>>def 1412c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1422c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1434e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil foo0bar 1444e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil abc0def 1452c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 1462c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 1472c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 148c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: foo<<X:([0-9]+)>>bar 149c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: abc<<X>>def 150c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: ### <<X>> ### 1512c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1522c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1532c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo1234bar 1542c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc1234def 1552c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil ### 1234 ### 1562c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 1572c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 1582c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 159c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: foo<<X:([0-9]+)>>bar 160c2c48ffdd623b4e58b34115d1521b0988a42b217David Brazdil // CHECK: abc<<X>>def 1612c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1622c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1632c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo1234bar 1642c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc1235def 1652c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 1662c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1674e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil def test_WholeWordMustMatch(self): 1684e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil self.assertTrue(self.matches( "// CHECK: b{{.}}r", "abc bar def")) 1694e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil self.assertFalse(self.matches( "// CHECK: b{{.}}r", "abc Xbar def")) 1704e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil self.assertFalse(self.matches( "// CHECK: b{{.}}r", "abc barX def")) 1714e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil self.assertFalse(self.matches( "// CHECK: b{{.}}r", "abc b r def")) 1724e9aac12cf5f88d565d0856a6f842f6c9280056dDavid Brazdil 1732c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_InOrderAssertions(self): 1742c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 1752c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1762c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: foo 1772c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: bar 1782c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1792c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1802c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 1812c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 1822c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 1832c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 1842c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1852c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: foo 1862c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: bar 1872c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1882c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1892c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 1902c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 1912c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 1922c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 1932c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_DagAssertions(self): 1942c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 1952c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 1962c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 1972c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: bar 1982c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 1992c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2002c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 2012c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 2022c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2032c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 2042c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2052c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 2062c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: bar 2072c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2082c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2092c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 2102c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 2112c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2122c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 2132c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_DagAssertionsScope(self): 2142c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 2152c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2162c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: foo 2172c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: abc 2182c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: def 2192c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: bar 2202c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2212c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2222c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 2232c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2242c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2252c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 2262c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2272c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 2282c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2292c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: foo 2302c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: abc 2312c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: def 2322c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: bar 2332c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2342c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2352c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 2362c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2372c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 2382c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2392c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2402c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 2412c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2422c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: foo 2432c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: abc 2442c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: def 2452c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: bar 2462c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2472c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2482c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 2492c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2502c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 2512c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2522c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2532c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 2542c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_NotAssertions(self): 2552c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 2562c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2572c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 2582c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2592c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2602c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2612c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2622c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2632c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 2642c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2652c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 2662c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2672c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2682c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc foo 2692c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2702c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2712c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 2722c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2732c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 2742c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: bar 2752c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2762c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2772c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2782c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def bar 2792c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2802c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 2812c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_NotAssertionsScope(self): 2822c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 2832c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2842c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: abc 2852c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 2862c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: def 2872c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2882c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2892c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 2902c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 2912c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 2922c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 2932c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2942c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: abc 2952c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 2962c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: def 2972c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 2982c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 2992c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 3002c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 3012c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 3022c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 3032c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 3042c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3052c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: abc 3062c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-NOT: foo 3072c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK: def 3082c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 3092c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3102c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 3112c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 3122c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def 3132c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 3142c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil 3152c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil def test_LineOnlyMatchesOnce(self): 3162c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertTrue(self.matches( 3172c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3182c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 3192c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 3202c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 3212c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3222c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 3232c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 3242c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 3252c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 3262c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil self.assertFalse(self.matches( 3272c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3282c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 3292c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil // CHECK-DAG: foo 3302c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """, 3312c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """ 3322c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil foo 3332c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil abc 3342c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil bar 3352c27f2ccf316aebf96cf365d33d2834a8206444dDavid Brazdil """)) 336