Skip to content
Browse files

Write the tests for categories.Object and categories.Morphism.

The tests do not pass at the moment.  The goal is to define the desired
behaviour of the methods in Morphism by means of tests.
  • Loading branch information...
1 parent fe78af1 commit 133bb56417f2ac1080959c2e4d4db7012890d429 @scolobb committed Jun 2, 2012
Showing with 62 additions and 0 deletions.
  1. +62 −0 sympy/categories/tests/test_baseclasses.py
View
62 sympy/categories/tests/test_baseclasses.py
@@ -0,0 +1,62 @@
+from sympy.categories import Object, Morphism
+
+def test_object():
+ A = Object("A")
+
+ assert A.name == "A"
+
+def test_morphism():
+ A = Object("A")
+ B = Object("B")
+ C = Object("C")
+ D = Object("D")
+
+ f = Morphism(A, B, "f")
+ g = Morphism(B, C, "g")
+ h = Morphism(C, D, "h")
+
+ assert f.name == "f"
+ assert f.domain == A
+ assert f.codomain == B
+ assert f.components == [f]
+
+ assert f * g == None
+ assert f * f == None
+
+ k = g.compose(f, "k")
+
+ assert k.domain == A
+ assert k.codomain == C
+ assert k.name == "k"
+ assert k.components == [f, g]
+
+ k = g * f
+ p = h * g
+ u = h * g * f
+
+ assert k.domain == A
+ assert k.codomain == C
+ assert k.name == "g f"
+ assert k.components == [f, g]
+
+ assert h * k == u
+ assert p * f == u
+
+ assert u.domain == A
+ assert u.codomain == D
+ assert u.name == "h g f"
+ assert u.components == [f, g, h]
+
+ u1 = u.flatten()
+
+ assert u1.domain == A
+ assert u1.codomain == D
+ assert u1.name == "h g f"
+ assert u1.components == [u1]
+
+ u1 = u.flatten("u")
+
+ assert u1.domain == A
+ assert u1.codomain == D
+ assert u1.name == "u"
+ assert u1.components == [u1]

0 comments on commit 133bb56

Please sign in to comment.
Something went wrong with that request. Please try again.