/[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.6 by benja, Sun Feb 23 23:13:04 2003 UTC revision 1.7 by benja, Sun Feb 23 23:44:56 2003 UTC
# Line 49  def list(set): Line 49  def list(set):
49  def testGetConnections():  def testGetConnections():
50      n[6].addProperty(p, n[1])      n[6].addProperty(p, n[1])
51            
52      c.set(n[0], n[1])      c.set(n[0], 1, n[1])
53      assert list(c.getConnections(1)) == [n[1]]      assert list(c.getConnections(1)) == [n[1]]
54      assert list(c.getConnections(-1)) == []      assert list(c.getConnections(-1)) == []
55    
56      c.set(n[1], n[2])      c.set(n[1], 1, n[2])
57      assert list(c.getConnections(1)) == [n[2]]      assert list(c.getConnections(1)) == [n[2]]
58      assert list(c.getConnections(-1)) == [n[0], n[6]]      assert list(c.getConnections(-1)) == [n[0], n[6]]
59    
60      c.set(n[2], n[3])      c.set(n[2], 1, n[3])
61      assert list(c.getConnections(1)) == n[3:]      assert list(c.getConnections(1)) == n[3:]
62      assert list(c.getConnections(-1)) == [n[1]]      assert list(c.getConnections(-1)) == [n[1]]
63    
64      c.set(n[6], n[1])      c.set(n[6], 1, n[1])
65      assert list(c.getConnections(1)) == [n[1]]      assert list(c.getConnections(1)) == [n[1]]
66      assert list(c.getConnections(-1)) == [n[2]]      assert list(c.getConnections(-1)) == [n[2]]
67    
68    
69  def testConnectedTwoWays():  def testConnectedTwoWays():
     """  
     fail: *  
     """  
70      n[5].addProperty(p, n[0])      n[5].addProperty(p, n[0])
71      n[5].addProperty(p, n[2])      n[5].addProperty(p, n[2])
72    
73      c.set(n[2], n[5])      c.set(n[2], 1, n[5])
74      c.move(1)      c.move(1)
75      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0
76    
# Line 82  def testConnectedTwoWays(): Line 79  def testConnectedTwoWays():
79    
80    
81  def testRotationIndex():  def testRotationIndex():
82      c.set(n[1], n[2])      c.set(n[1], 1, n[2])
83      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0
84    
85      c.set(n[2], n[5])      c.set(n[2], 1, n[5])
86      assert c.getRotationIndex() == 2      assert c.getRotationIndex() == 2
87    
88      c.set(n[2], n[9])      c.set(n[2], 1, n[9])
89      assert c.getRotationIndex() == 6      assert c.getRotationIndex() == 6
90    
91      c.set(n[4], None)      c.set(n[4], 0, None)
92      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0
93    
94    
# Line 99  def testRotateMoveLeft(): Line 96  def testRotateMoveLeft():
96      n[4].addProperty(p, n[5])      n[4].addProperty(p, n[5])
97      n[6].addProperty(p, n[5])      n[6].addProperty(p, n[5])
98    
99      c.set(n[5], n[4])      c.set(n[5], -1, n[4])
100    
101      assert c.getRotationIndex() == 1      assert c.getRotationIndex() == 1
102      c.rotate(-1)      c.rotate(-1)
# Line 115  def testRotateMoveLeft(): Line 112  def testRotateMoveLeft():
112      assert c.getRotationIndex() == 2      assert c.getRotationIndex() == 2
113      assert c.rotation == n[6]      assert c.rotation == n[6]
114    
115      c.set(n[5], None)      c.set(n[5], 0, None)
116    
117      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0
118      c.rotate(-1)      c.rotate(-1)
# Line 124  def testRotateMoveLeft(): Line 121  def testRotateMoveLeft():
121      assert c.getRotationIndex() == 1      assert c.getRotationIndex() == 1
122      assert c.rotation == n[4]      assert c.rotation == n[4]
123    
124      c.set(n[5], None)      c.set(n[5], 0, None)
125      c.rotate(1)      c.rotate(1)
126      assert c.getRotationIndex() == 1      assert c.getRotationIndex() == 1
127      assert c.rotation == n[4]      assert c.rotation == n[4]
# Line 134  def testRotateMoveLeft(): Line 131  def testRotateMoveLeft():
131            
132    
133  def testRotateMove():  def testRotateMove():
134      c.set(n[2], n[5])      c.set(n[2], 1, n[5])
135      c.rotate(1)      c.rotate(1)
136      assert c.focus == n[2] and c.rotation == n[6]      assert c.focus == n[2] and c.rotation == n[6] and c.dir == 1
137      c.rotate(1)      c.rotate(1)
138      assert c.focus == n[2] and c.rotation == n[7]      assert c.focus == n[2] and c.rotation == n[7] and c.dir == 1
139      c.rotate(-1)      c.rotate(-1)
140      assert c.focus == n[2] and c.rotation == n[6]      assert c.focus == n[2] and c.rotation == n[6] and c.dir == 1
141    
142      c.set(n[2], n[9])      c.set(n[2], 1, n[9])
143      c.rotate(1)      c.rotate(1)
144      assert c.focus == n[2] and c.rotation == n[9]      assert c.focus == n[2] and c.rotation == n[9]
145      c.rotate(-1)      c.rotate(-1)
# Line 152  def testRotateMove(): Line 149  def testRotateMove():
149      c.rotate(1)      c.rotate(1)
150      assert c.focus == n[2] and c.rotation == n[9]      assert c.focus == n[2] and c.rotation == n[9]
151    
152      c.set(n[2], n[1])      c.set(n[2], -1, n[1])
153      assert c.getRotationIndex() == 0      assert c.getRotationIndex() == 0 and c.dir == -1
154      c.rotate(1)      c.rotate(1)
155      assert c.getRotationIndex() == 1      assert c.getRotationIndex() == 1 and c.dir == 1
156      c.rotate(1)      c.rotate(1)
157      assert c.getRotationIndex() == 2      assert c.getRotationIndex() == 2 and c.dir == 1
158        c.move(-1)
159        assert c.focus == n[2] and c.getRotationIndex() == 2 and \
160               c.dir == 1
161      c.move(1)      c.move(1)
162      assert c.focus == n[5] and c.rotation == n[2]      assert c.focus == n[5] and c.rotation == n[2] and c.dir == -1
163    
164      c.set(n[2], n[3])      c.set(n[2], 1, n[3])
165      c.rotate(-1)      c.rotate(-1)
166      assert c.focus == n[2] and c.rotation == n[3]      assert c.focus == n[2] and c.rotation == n[3] and c.dir == 1
167    
168      c.move(-1)      c.move(-1)
169      assert c.focus == n[1] and c.rotation == n[2]      assert c.focus == n[1] and c.rotation == n[2] and c.dir == 1
170      c.move(-1)      c.move(-1)
171      assert c.focus == n[0] and c.rotation == n[1]      assert c.focus == n[0] and c.rotation == n[1] and c.dir == 1
172      c.move(1)      c.move(1)
173      assert c.focus == n[1] and c.rotation == n[0]      assert c.focus == n[1] and c.rotation == n[0] and c.dir == -1
174      c.move(1)      c.move(1)
175      assert c.focus == n[2] and c.rotation == n[1]      assert c.focus == n[2] and c.rotation == n[1] and c.dir == -1
176    
177    
178      # if we cannot move there, we remain where we are:      # if we cannot move there, we remain where we are:
179    
180      c.set(n[2], n[7])      c.set(n[2], 1, n[7])
181      c.move(-1)      c.move(-1)
182      assert c.focus == n[2] and c.rotation == n[7]      assert c.focus == n[2] and c.rotation == n[7] and c.dir == 1
183    
184      c.set(n[0], n[1])      c.set(n[0], 1, n[1])
185      c.move(-1)      c.move(-1)
186      assert c.focus == n[0] and c.rotation == n[1]      assert c.focus == n[0] and c.rotation == n[1] and c.dir == 1
187    
188    
189    def testRotationChangesDir():
190        n[7].addProperty(p, n[1])
191    
192        c.set(n[2], -1, n[1])
193        assert c.getRotationIndex() == 0 and c.dir == -1
194        c.rotate(1)
195        assert c.getRotationIndex() == 1 and c.dir == 1
196    
197        c.set(n[1], 1, n[2])
198        assert c.getRotationIndex() == 0 and c.dir == 1
199        c.rotate(1)
200        assert c.getRotationIndex() == 1 and c.dir == -1

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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