gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/test test.py testutil.py gzz/dim.py gzz/any...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/test test.py testutil.py gzz/dim.py gzz/any...
Date: Sat, 12 Oct 2002 08:58:37 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/10/12 08:58:37

Modified files:
        test           : test.py testutil.py 
        test/gzz       : dim.py 
Added files:
        test/gzz       : anydim.py readwritedim.py 
        test/gzz/diff  : deltadim.py 
        test/gzz/impl  : normaldim.test simpledim.test 

Log message:
        Move tests from test.py to .test files

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/test.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/testutil.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/anydim.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/readwritedim.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/dim.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/diff/deltadim.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/impl/normaldim.test?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/impl/simpledim.test?rev=1.1

Patches:
Index: gzz/test/gzz/dim.py
diff -c gzz/test/gzz/dim.py:1.8 gzz/test/gzz/dim.py:1.9
*** gzz/test/gzz/dim.py:1.8     Tue Sep 17 14:56:41 2002
--- gzz/test/gzz/dim.py Sat Oct 12 08:58:37 2002
***************
*** 24,178 ****
  import unittest
  from java import io
  
- def makeRank(dim, l):
-     for i in range(0, len(l)-1):
-       dim.connect(l[i], l[i+1])
- 
- class TestAnyDim(unittest.TestCase):
-     # Requires attributes:
-     # cells = sequence of cells, with nontrivial structure. 
-     # Having ringranks would be good.
-     # dim = dimension
-     def testStepNeg(self):
-       "Test that stepping forwards and back gets us back."
-       for c in self.cells:
-           self.failUnlessEqual(self.dim.s(c, 0), c)
-           for n in range(-10,10):
-               end = self.dim.s(c, n)
-               if end == None : continue
-               self.failUnlessEqual(self.dim.s(end, -n), c)
- 
-     def testHeads(self):
-       "Test assumptions about headcells and ringranks"
-       for c in self.cells:
-           head = self.dim.h(c)
-           tail = self.dim.h(c,1)
-           if self.dim.s(head, -1) != None:
-               self.failUnlessEqual(self.dim.s(head, -1), tail)
-               self.failUnlessEqual(self.dim.s(tail, 1), head)
-           else:
-               self.failUnlessEqual(head, self.dim.h(tail))
-               self.failUnlessEqual(tail, self.dim.h(head, 1))
- 
-     # XXX test Iterators
- 
-     def assertFullRank(self, dim, cells):
-       if len(cells) == 0:
-           return
-       cells = [self.rcells[c] for c in cells]
-       self.failUnlessEqual(dim.s(cells[0], -1), None)
-       self.failUnlessEqual(dim.s(cells[-1], 1), None)
-       for i in range(0,len(cells)-1):
-           self.failUnlessEqual(dim.s(cells[i], 1), cells[i+1])
-           self.failUnlessEqual(dim.s(cells[i+1], -1), cells[i])
- 
- class TestReadWriteDim(TestAnyDim):
-     # Requires attribute:
-     # space, dim
-     def setUp(self):
-       self.cells = [self.space.N() for i in range(0,10)]
-       makeRank(self.dim, self.cells[0:3]) # plain rank
-       makeRank(self.dim, self.cells[3:7])
-       self.dim.connect(self.cells[7], self.cells[3]) # ringrank
-       self.dim.connect(self.cells[8], self.cells[8]) # 1-cell ringrank
-       # self.cells[9] = a single cell
- 
-       self.loosecells = [self.space.N() for i in range(0,10)]
- 
-       TestAnyDim.setUp(self)
- 
-     def test_RW_Empty(self):
-       "The dimension must not have any connections for loosecells."
-       for c in self.loosecells:
-           self.failUnlessEqual([c, None, None, None, None],
-               [self.dim.s(c, steps) for steps in [0,1,-1,2,-2]])
-               
-     def testDelete(self):
-         """Delete must excise"""
-         c = self.cells
-       dim = self.dim
- 
-       assert c[0].s(dim) == c[1]
-       assert c[1].s(dim) == c[2]
- 
-       c[1].delete()
- 
-       assert c[0].s(dim) == c[2]
-       assert not (c[1].s(dim) or c[1].s(dim, -1))
- 
- class TestDeltaDim(TestReadWriteDim):
-     # Requires attribute: space, dim.
- 
-     def checkpointDelta(self):
-       return self.space.checkpointDelta()
-     def applyDelta(self, delta):
-       self.space.applyDelta(delta)
- 
-     def test_DD_ops(self):
-       "Test basic delta operations"
-       self.rcells = self.loosecells
-       dim = self.dim
- 
-       def conn(a,b):
-           dim.connect(self.rcells[a], self.rcells[b])
-       def disconn(a,dir):
-           dim.disconnect(self.rcells[a], dir)
- 
-       def asRank(*args):
-           for rank in args:
-               self.assertFullRank(dim, rank)
- 
-       conn(6,7)
-       conn(0,1)
- 
-       self.checkpointDelta()
- 
-       # 0-1 6-7
-       asRank([0,1], [6,7])
- 
-       conn(1,2)
-       disconn(6, +1)
- 
-       # 0-1-2 6 7
-       asRank([0,1, 2], [6], [7])
- 
-       self.failUnlessRaises(ZZAlreadyConnectedException, 
-           conn, 0, 3)
-       self.failUnlessRaises(ZZAlreadyConnectedException, 
-           conn, 4, 2)
- 
-       delta = self.checkpointDelta()
- 
-       asRank([0,1, 2], [6], [7])
- 
-       self.applyDelta(delta.inverse())
-       
-       asRank([0,1], [6,7])
- 
-       self.applyDelta(delta)
-       asRank([0,1, 2], [6], [7])
- 
-       zeroDelta = self.space.getDeltaFromZero()
- 
-       self.failUnlessRaises(InconsistentChangeException,
-           self.applyDelta, delta)
-       # Now self.space is inconsistent.
- 
-       ous = io.ByteArrayOutputStream()
-       io.ObjectOutputStream(ous).writeObject(zeroDelta)
-       ins = io.ByteArrayInputStream(ous.toByteArray())
-       newDelta = io.ObjectInputStream(ins).readObject()
- 
-       # But we have zeroDelta and now just set up again
-       # and see that zeroDelta is usable in the new space.
-       self.setUp()
- 
-       self.newDelta = newDelta
-       self.applyDelta(newDelta)
- 
-       self.rcells = [self.space.getCell(c.id) for c in self.rcells]
-       dim = self.dim
- 
-       asRank([0,1, 2], [6], [7])
- 
- 
--- 24,26 ----
Index: gzz/test/test.py
diff -c gzz/test/test.py:1.20 gzz/test/test.py:1.21
*** gzz/test/test.py:1.20       Mon Sep 30 18:20:28 2002
--- gzz/test/test.py    Sat Oct 12 08:58:36 2002
***************
*** 43,62 ****
  
  import unittest
  
- class TestSimpleDim(test.gzz.dim.TestReadWriteDim):
-     def setUp(self):
-       self.space = apply(ModularSpace, spaceArgList())
-       self.dim = self.space.getDim(self.space.N())
-       test.gzz.dim.TestReadWriteDim.setUp(self)
- 
- class TestNormalDim(test.gzz.dim.TestDeltaDim):
-     def setUp(self):
-       self.space = apply(ModularDeltaSpace, deltaspaceArgList())
-       if not hasattr(self, "dimId"):
-           self.dimId = self.space.N().getId()
-       self.dim = self.space.getDim(self.dimId)
-       test.gzz.dim.TestDeltaDim.setUp(self)
- 
  
  class TestVStreamContent(test.gzz.content.TestRWSpanContent):
      def setUp(self):
--- 43,48 ----
Index: gzz/test/testutil.py
diff -c gzz/test/testutil.py:1.21 gzz/test/testutil.py:1.22
*** gzz/test/testutil.py:1.21   Sat Oct 12 06:18:08 2002
--- gzz/test/testutil.py        Sat Oct 12 08:58:36 2002
***************
*** 75,80 ****
--- 75,82 ----
      return tests
  
  faildefs = compile("""
+ def failUnlessRaises(*args):
+     unittestObject.failUnlessRaises(*args)
  def failUnlessApprox(delta, first, second, msg = None):
      unittestObject.failUnless(abs(first-second) <= delta, msg)
  def failIfApprox(delta, first, second, msg = None):




reply via email to

[Prev in Thread] Current Thread [Next in Thread]