"""Tests for ``xentica.core.variables`` module."""
import unittest

from xentica.core.variables import IntegerVariable
from xentica import core


class TestVariable(unittest.TestCase):
    """Tests for ``Variable`` class and its children."""

    def test_integer(self):
        """Test ``IntegerVariable`` initialization."""
        IntegerVariable()

    def test_descriptor(self):
        """Test ``Variable`` acting as class descriptor."""
        class InvertCA(core.CellularAutomaton):
            state = core.IntegerProperty(max_val=1)

            class Topology:
                dimensions = 2
                lattice = core.OrthogonalLattice()
                neighborhood = core.MooreNeighborhood()
                border = core.TorusBorder()

            def emit(self):
                pass

            def absorb(self):
                # really weird way to declare variables
                # but at least it work with current system
                self.__class__.intvar = IntegerVariable()
                self.intvar = self.main.state
                self.main.state = -self.intvar

            def color(self):
                pass

@@ -326,16 +326,22 @@
 %0A       
+ var =
  Integer
@@ -350,16 +350,82 @@
 riable()
+%0A        self.assertEqual(str(var), %22var%22, %22Wrong variable name.%22)
 %0A%0A    de
@@ -505,24 +505,25 @@
 criptor.%22%22%22%0A
+%0A
         clas
@@ -558,16 +558,79 @@
 maton):%0A
+            %22%22%22CA that inverts each cell's value each step.%22%22%22%0A
         
@@ -702,16 +702,60 @@
 pology:%0A
+                %22%22%22Most common topology.%22%22%22%0A
         
@@ -977,43 +977,113 @@
     
-pass%0A%0A            def absorb(self):
+%22%22%22Do nothing at emit phase.%22%22%22%0A%0A            def absorb(self):%0A                %22%22%22Invert cell's value.%22%22%22
 %0A   
@@ -1395,9 +1395,155 @@
     
-pass
+%22%22%22Do nothing, no color processing required.%22%22%22%0A%0A        self.assertEqual(InvertCA.__name__, %22InvertCA%22,%0A                         %22Wrong class name.%22)
 %0A

Fix pylint issues in tests.core.test_variables (#30)