Philip Xu avatar Philip Xu committed f4792fb

Improved test_compose.

- covers all permutations of f, g, h compositions
- uses 'type' instead of 'hash' as function h, 'hash' acts as identity
function on int, which is inappropriate here.

Comments (0)

Files changed (1)

tests/test_utils.py

     # different orders, yield different outputs.
     f = id
     g = str
-    h = hash
+    h = type
 
     f1 = compose(f, compose(g, h))
     f2 = compose(compose(f, g), h)
 
-    ns = [42, '42', sum, f]
+    ns = [42, 0.5, '42', sum, f, lambda: 0]
     for n in ns:
         # make sure these functions yield different outputs when composed in
         # different order,
         assert f2(n) != compose(f, compose(h, g))(n)
         assert f1(n) != compose(g, compose(f, h))(n)
         assert f2(n) != compose(g, compose(f, h))(n)
+        assert f1(n) != compose(g, compose(h, f))(n)
+        assert f2(n) != compose(g, compose(h, f))(n)
         assert f1(n) != compose(h, compose(g, f))(n)
         assert f2(n) != compose(h, compose(g, f))(n)
+        assert f1(n) != compose(h, compose(f, g))(n)
+        assert f2(n) != compose(h, compose(f, g))(n)
         # but compose should obey associative law.
         assert f1(n) == f2(n)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.