#!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 15.08.2017 15:31
:Licence GNUv3
Part of grammpy

"""

from unittest import main, TestCase
from grammpy import *
from .grammar import *


class RulesTest(TestCase):
    def test_oneRules(self):
        class Tmp1(Rule):
            rules = [([NFirst], [NSecond, 0]),
                     ([NThird], [0, 1]),
                     ([NSecond], [NSecond, 'a'])]
        grammar.add_rule(Tmp1)


if __name__ == '__main__':
    main()

@@ -212,24 +212,359 @@
 (TestCase):%0A
+    def setUp(self):%0A        self.g = Grammar(terminals=%5B0, 1, 2,%0A                                    'a', 'b', 'c',%0A                                    TFirst, TSecond, TThird,%0A                                    TInstFirst, TInstSecond, TInstThird%5D,%0A                         nonterminals=%5BNFirst, NSecond, NThird, NFourth, NFifth%5D)%0A%0A
     def test
@@ -567,16 +567,18 @@
 test_one
+In
 Rules(se
@@ -758,31 +758,895 @@
     
-grammar.add_rule(Tmp1)%0A
+self.g.add_rule(Tmp1)%0A        self.assertEqual(self.g.rules_count(), 3)%0A        self.assertTrue(self.g.have_rule(Tmp1))%0A%0A    def test_oneInRulesIteration(self):%0A        class Tmp1(Rule):%0A            rules = %5B(%5BNFirst%5D, %5BNSecond, 0%5D),%0A                     (%5BNThird%5D, %5B0, 1%5D),%0A                     (%5BNSecond%5D, %5BNSecond, 'a'%5D)%5D%0A        self.g.add_rule(Tmp1)%0A        for rule in self.g.rule():%0A            self.assertIn(rule.rule, Tmp1.rules)%0A%0A    def test_hashes(self):%0A        class Tmp1(Rule):%0A            rules = %5B(%5BNFirst%5D, %5BNSecond, 0%5D),%0A                     (%5BNThird%5D, %5B0, 1%5D),%0A                     (%5BNSecond%5D, %5BNSecond, 'a'%5D)%5D%0A        class Tmp2(Rule):%0A            rules = %5B(%5BNFirst%5D, %5BNSecond, 0%5D),%0A                     (%5BNThird%5D, %5B0, 1%5D),%0A                     (%5BNSecond%5D, %5BNSecond, 'a'%5D)%5D%0A        hash1 = hash(Tmp1)%0A        hash2 = hash(Tmp2)%0A        self.assertEqual(hash1, hash2)
 %0A%0Aif

Add test that check hash values of rule