tests.st 1.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/usr/bin/gst-sunit -f

FileStream fileIn: 'coord.st'.
FileStream fileIn: 'cell.st'.
FileStream fileIn: 'world.st'.

TestCase subclass: ConwayTests [
    testBlock [
        | alive original next |
10
        'testBlock' displayNl.
11
12
13
        alive := World block:(Coord newWithX:0 y:0).
        original := World newWithSize:5 aliveCells:alive.
        next := original evolve.
14
        self assert: next = original ]
15
16
17

    testTub [
        | alive original next |
18
        'testTub' displayNl.
19
20
21
        alive := World tub:(Coord newWithX:0 y:0).
        original := World newWithSize:5 aliveCells:alive.
        next := original evolve.
22
        self assert: next = original ]
23
24
25

    testBlinker [
        | alive original gen1 gen2 expectedAlive expected |
26
        'testBlinker' displayNl.
27
28
29
30
31
32
33
34
35
36
        alive := World blinker:(Coord newWithX:0 y:1).
        original := World newWithSize:3 aliveCells:alive.
        gen1 := original evolve.
        expectedAlive := Set new.
        expectedAlive add:(Coord newWithX:1 y:0).
        expectedAlive add:(Coord newWithX:1 y:1).
        expectedAlive add:(Coord newWithX:1 y:2).
        expected := World newWithSize:3 aliveCells:expectedAlive.
        self assert: expected = gen1.
        gen2 := gen1 evolve.
37
        self assert: original = gen2 ] ]
38
39

ConwayTests suite run.