/[gzz]/gzz/lava/test/gzz/loom/Cursor.test
ViewVC logotype

Diff of /gzz/lava/test/gzz/loom/Cursor.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by benja, Sun Feb 23 21:11:35 2003 UTC revision 1.5 by benja, Sun Feb 23 23:00:55 2003 UTC
# Line 35  for i in range(3,10): Line 35  for i in range(3,10):
35    
36  class Cmp(java.util.Comparator):  class Cmp(java.util.Comparator):
37      def compare(self, r1, r2):      def compare(self, r1, r2):
38            if (not r1) or (not r2):
39                raise java.lang.NullPointerException("r1=%r, r2=%r" % (r1, r2))
40          return n.index(r1) - n.index(r2)          return n.index(r1) - n.index(r2)
41  c = gzz.loom.Cursor(Cmp())  c = gzz.loom.Cursor(Cmp())
42    
# Line 78  def testRotationIndex(): Line 80  def testRotationIndex():
80      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0
81    
82    
83    def testRotateMoveLeft():
84        n[4].addProperty(p, n[5])
85        n[6].addProperty(p, n[5])
86    
87        c.set(n[5], n[4])
88    
89        assert c.getRotationIndex() == 1
90        c.rotate(-1)
91        assert c.getRotationIndex() == 0
92        assert c.rotation == n[2]
93        c.rotate(-1)
94        assert c.getRotationIndex() == 0
95        c.rotate(1)
96        assert c.getRotationIndex() == 1
97        c.rotate(1)
98        assert c.getRotationIndex() == 2
99        c.rotate(1)
100        assert c.getRotationIndex() == 2
101        assert c.rotation == n[6]
102    
103        c.set(n[5], None)
104    
105        assert c.getRotationIndex() == 0
106        c.rotate(-1)
107        assert c.getRotationIndex() == 0
108        c.rotate(1)
109        assert c.getRotationIndex() == 1
110        assert c.rotation == n[4]
111    
112        c.set(n[5], None)
113        c.rotate(1)
114        assert c.getRotationIndex() == 1
115        assert c.rotation == n[4]
116    
117        c.move(-1)
118        assert c.focus == n[4] and c.rotation == n[5]
119        
120    
121  def testRotateMove():  def testRotateMove():
122      c.set(n[2], n[5])      c.set(n[2], n[5])
123      c.rotate(1)      c.rotate(1)
# Line 97  def testRotateMove(): Line 137  def testRotateMove():
137      c.rotate(1)      c.rotate(1)
138      assert c.focus == n[2] and c.rotation == n[9]      assert c.focus == n[2] and c.rotation == n[9]
139    
140        c.set(n[2], n[1])
141        assert c.getRotationIndex() == 0
142        c.rotate(1)
143        assert c.getRotationIndex() == 1
144        c.rotate(1)
145        assert c.getRotationIndex() == 2
146        c.move(1)
147        assert c.focus == n[5] and c.rotation == n[2]
148    
149      c.set(n[2], n[3])      c.set(n[2], n[3])
150      c.rotate(-1)      c.rotate(-1)
151      assert c.focus == n[2] and c.rotation == n[3]      assert c.focus == n[2] and c.rotation == n[3]
# Line 106  def testRotateMove(): Line 155  def testRotateMove():
155      c.move(-1)      c.move(-1)
156      assert c.focus == n[0] and c.rotation == n[1]      assert c.focus == n[0] and c.rotation == n[1]
157      c.move(1)      c.move(1)
158      assert c.focus == n[1] and c.rotation == n[2]      assert c.focus == n[1] and c.rotation == n[0]
159      c.move(1)      c.move(1)
160      assert c.focus == n[2] and c.rotation == n[3]      assert c.focus == n[2] and c.rotation == n[1]
161    
162    
163        # if we cannot move there, we remain where we are:
164    
165        c.set(n[2], n[7])
166        c.move(-1)
167        assert c.focus == n[2] and c.rotation == n[7]
168    
169        c.set(n[0], n[1])
170        c.move(-1)
171        assert c.focus == n[0] and c.rotation == n[1]

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26