Merged revisions 66805,66841,66860,66884-66886,66893,66907,66910 via svnmerge from

svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

........
  r66805 | benjamin.peterson | 2008-10-04 20:11:02 -0500 (Sat, 04 Oct 2008) | 1 line

  mention what the fixes directory is for
........
  r66841 | benjamin.peterson | 2008-10-07 17:48:12 -0500 (Tue, 07 Oct 2008) | 1 line

  use assertFalse and assertTrue
........
  r66860 | benjamin.peterson | 2008-10-08 16:05:07 -0500 (Wed, 08 Oct 2008) | 1 line

  instead of abusing the pattern matcher, use start_tree to find a next binding
........
  r66884 | benjamin.peterson | 2008-10-13 15:50:30 -0500 (Mon, 13 Oct 2008) | 1 line

  don't print tokens to stdout when -v is given
........
  r66885 | benjamin.peterson | 2008-10-13 16:28:57 -0500 (Mon, 13 Oct 2008) | 1 line

  add the -x option to disable fixers
........
  r66886 | benjamin.peterson | 2008-10-13 16:33:53 -0500 (Mon, 13 Oct 2008) | 1 line

  cut down on some crud
........
  r66893 | benjamin.peterson | 2008-10-14 17:16:54 -0500 (Tue, 14 Oct 2008) | 1 line

  add an optional set literal fixer
........
  r66907 | benjamin.peterson | 2008-10-15 16:59:41 -0500 (Wed, 15 Oct 2008) | 1 line

  don't write backup files by default
........
  r66910 | benjamin.peterson | 2008-10-15 17:43:10 -0500 (Wed, 15 Oct 2008) | 1 line

  add the -n option; it stops backupfiles from being written
........
This commit is contained in:
Benjamin Peterson 2008-10-15 23:10:28 +00:00
parent 1fb84519b1
commit 6ae94ee299
8 changed files with 248 additions and 53 deletions

View file

@ -353,29 +353,29 @@ class TestPatterns(support.TestCase):
# Build a pattern matching a leaf
pl = pytree.LeafPattern(100, "foo", name="pl")
r = {}
self.assertEqual(pl.match(root, results=r), False)
self.assertFalse(pl.match(root, results=r))
self.assertEqual(r, {})
self.assertEqual(pl.match(n1, results=r), False)
self.assertFalse(pl.match(n1, results=r))
self.assertEqual(r, {})
self.assertEqual(pl.match(n2, results=r), False)
self.assertFalse(pl.match(n2, results=r))
self.assertEqual(r, {})
self.assertEqual(pl.match(l1, results=r), True)
self.assertTrue(pl.match(l1, results=r))
self.assertEqual(r, {"pl": l1})
r = {}
self.assertEqual(pl.match(l2, results=r), False)
self.assertFalse(pl.match(l2, results=r))
self.assertEqual(r, {})
# Build a pattern matching a node
pn = pytree.NodePattern(1000, [pl], name="pn")
self.assertEqual(pn.match(root, results=r), False)
self.assertFalse(pn.match(root, results=r))
self.assertEqual(r, {})
self.assertEqual(pn.match(n1, results=r), False)
self.assertFalse(pn.match(n1, results=r))
self.assertEqual(r, {})
self.assertEqual(pn.match(n2, results=r), True)
self.assertTrue(pn.match(n2, results=r))
self.assertEqual(r, {"pn": n2, "pl": l3})
r = {}
self.assertEqual(pn.match(l1, results=r), False)
self.assertFalse(pn.match(l1, results=r))
self.assertEqual(r, {})
self.assertEqual(pn.match(l2, results=r), False)
self.assertFalse(pn.match(l2, results=r))
self.assertEqual(r, {})
def testWildcardPatterns(self):
@ -391,11 +391,11 @@ class TestPatterns(support.TestCase):
pn = pytree.NodePattern(1000, [pl], name="pn")
pw = pytree.WildcardPattern([[pn], [pl, pl]], name="pw")
r = {}
self.assertEqual(pw.match_seq([root], r), False)
self.assertFalse(pw.match_seq([root], r))
self.assertEqual(r, {})
self.assertEqual(pw.match_seq([n1], r), False)
self.assertFalse(pw.match_seq([n1], r))
self.assertEqual(r, {})
self.assertEqual(pw.match_seq([n2], r), True)
self.assertTrue(pw.match_seq([n2], r))
# These are easier to debug
self.assertEqual(sorted(r.keys()), ["pl", "pn", "pw"])
self.assertEqual(r["pl"], l1)
@ -404,7 +404,7 @@ class TestPatterns(support.TestCase):
# But this is equivalent
self.assertEqual(r, {"pl": l1, "pn": n2, "pw": [n2]})
r = {}
self.assertEqual(pw.match_seq([l1, l3], r), True)
self.assertTrue(pw.match_seq([l1, l3], r))
self.assertEqual(r, {"pl": l3, "pw": [l1, l3]})
self.assert_(r["pl"] is l3)
r = {}