Title: Tests for writable Gzz dimensions Ly version: 0.1 Show title: + Easy tags: + Tangler: test.util.TestTangler Extends test: Dim.spec -- Introduction -- XXX MOCKUP: This code is not actually used at the moment! Ly needs a lot of work before it can weave & tangle this. The intent is that the code in here is run as a |unittest| class, while the woven HTML is put into the |doc/| directory. This document contains unit tests for dimensions which allow changing their connections. (XXX) |.test| files for specific dimension implementations must set the following variables:
|dim|
The |Dim| object to test.
-- Set up -- def makeRank(l): """Connect a list of cells into a rank.""" for i in range(0, len(l)-1): dim.connect(l[i], l[i+1]) We create and connect some cells ourselves. This contrasts with what |Dim.spec| does: in |Dim.spec|, we do not assume the ability to create connections on the dimension, so we need to rely on implementation-specific code to create the test setup for us. space = dim.getSpace() cells = [space.N() for i in range(0, 10)] makeRank(cells[0:3]) # a plain rank makeRank(cells[3:7]) dim.connect(cells[7], cells[3]) # a ringrank dim.connect(cells[8], cells[8]) # a single-cell ringrank We leave |cells[9]| unconnected, because the behavior of a dimension must be tested for unconnected cells, too. Finally, we also create an list of unconnected ("loose") cells which we may connect later in our tests. loosecells = [space.N() for i in range(0, 10)] -- Test that freshly created cells aren't connected -- We check that the dimension doesn't initially assume any connections for the cells we have just created. for c in loosecells: assert not (c.s(dim, 1) or c.s(dim, -1)) We also check that walking more than one step in each direction will not give an inconsistent result. assert not (c.s(dim, 2) or c.s(dim, -2))