added a test for the pattern

--HG--
rename : bin/pattern.py => test/pattern.py
This commit is contained in:
Stephen McQuay 2011-02-15 11:10:00 -07:00
parent ea8821fbff
commit 28711318d5

52
test/pattern.py Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
import unittest
from interp.baker import pattern
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
pass
def testImports(self):
from interp.baker import pattern
def test0(self):
b = sorted([tuple(sorted(i)) for i in ((1,2),(2,3),(3,1))])
p = sorted(pattern(power = 2, phicount = 3))
self.assertEqual(b,p)
def test1(self):
b = sorted([tuple(sorted(i)) for i in ((1,2,2), (1,3,3), (2,1,1), (2,3,3), (3,1,1), (3,2,2), (1,2,3))])
p = sorted(pattern(power = 3, phicount = 3))
self.assertEqual(b,p)
def test2(self):
b = sorted([tuple(sorted(i)) for i in (
(1,2), (1,3), (1,4),
(2,3), (2,4), (3,4))])
p = sorted(pattern(power = 2, phicount = 4))
self.assertEqual(b,p)
def test3(self):
b = sorted([tuple(sorted(i)) for i in (
(1,2,3), (2,3,4), (1,2,4), (1,3,4),
(1,1,2), (1,2,2),
(2,3,3), (2,2,3),
(1,3,3), (1,1,3),
(2,4,4), (2,2,4),
(3,3,4), (3,4,4),
(1,4,4), (1,1,4))])
p = sorted(pattern(power = 3, phicount = 4))
self.assertEqual(b,p)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)
unittest.TextTestRunner(verbosity=3).run(suite)