Commits

Armin Rigo  committed b32ed6a

More tests.

  • Participants
  • Parent commits e9b36ee

Comments (0)

Files changed (1)

File hack/stm/transactionmodule/test_transaction.py

-import transaction
+import py, transaction
 
 def test_simple():
     lst = []
     transaction.add(lst.append, 7)
     transaction.run()
     assert sorted(lst) == [5, 6, 7]
+
+def test_add_more():
+    lst = []
+    def do(x):
+        lst.append(x)
+        if x < 10:
+            transaction.add(do, x + 1)
+    transaction.add(do, 0)
+    transaction.run()
+    assert lst == range(11)
+
+def test_exception():
+    def do(x):
+        raise ValueError
+    transaction.add(do, 5)
+    py.test.raises(ValueError, transaction.run)
+
+def test_no_recursion():
+    def do(x):
+        transaction.run()
+    transaction.add(do, 5)
+    py.test.raises(transaction.TransactionError, transaction.run)