Commits

Maxim Moiseev  committed 3a5d8e6

reshuffled test suite files a bit

  • Participants
  • Parent commits 0e27f43

Comments (0)

Files changed (2)

File foonctest/__init__.py

 import sys
 import unittest
 
-import foonc
+import foonctest
 
 def suite():
     suite = unittest.TestSuite()
-    suite.addTests(foonc.suite())
+    suite.addTests(foonctest.suite())
     return suite
 
 if __name__ == '__main__':

File foonctest/foonctest.py

+import unittest
+
+from foonc import foonc
+
+def inc(x):
+    return x + 1
+
+class FooncTests(unittest.TestCase):
+    def setUp(self):
+        super(FooncTests, self).setUp()
+
+    def test_const(self):
+        self.assertEqual(42, foonc.const(42)('whatever', is_passed='in'))
+
+    def test_compose2(self):
+        f = foonc._compose2(inc, int)
+        self.assertEqual(42, f('41'))
+
+    def test_compose_args(self):
+        f = foonc.compose(str, inc, int)
+        self.assertEqual('42', f('41'))
+
+    def test_compose_list(self):
+        f = foonc.compose([str, inc, int])
+        self.assertEqual('42', f('41'))
+
+    def test_flip(self):
+        def f(*args):
+            return args
+        flipped = foonc.flip(f)
+        self.assertEqual((3, 2, 1), flipped(1, 2, 3))
+
+
+class FooncWrapperTests(unittest.TestCase):
+    def setUp(self):
+        super(FooncWrapperTests, self).setUp()
+
+    def test_left_shift(self):
+        f = foonc.wrap(int) >> inc
+        self.assertEqual(42, f('41'))
+
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTests(unittest.makeSuite(FooncTests))
+    suite.addTests(unittest.makeSuite(FooncWrapperTests))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()