# Path: pydsl/equal.py
# def equal_factory(definition):
#     from pydsl.grammar.definition import String
#     if isinstance(definition, String):
#         return lambda x,y: x==y
# 
# def equal(definition, first_element, second_element) -> bool:
#     """Compares if the two elements are equal according to the grammar definition"""
#     if not check(definition, first_element):
#         raise ValueError
#     if not check(definition, second_element):
#         raise ValueError
#     equal_checker = equal_factory(definition)
#     return equal_checker(first_element, second_element)
# 
# Path: pydsl/grammar/definition.py
# class String(Grammar, str):
#     def __init__(self, string):
#         if isinstance(string, list):
#             raise TypeError('Attempted to initialize a String with a list %s' % (string, ) )
#         Grammar.__init__(self, None)
# 
#     @property
#     def first(self):
#         return String(self[0])
# 
#     def enum(self):
#         yield self
# 
#     @property
#     def maxsize(self):
#         return len(self)
# 
#     @property
#     def minsize(self):
#         return len(self)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding


import unittest
from pydsl.equal import equal_factory, equal
from pydsl.grammar.definition import String
#!/usr/bin/env python
#This file is part of pydsl.
#
#pydsl is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with pydsl.  If not, see <http://www.gnu.org/licenses/>.

__author__ = "Nestor Arocha"
__copyright__ = "Copyright 2008-2020, Nestor Arocha"
__email__ = "nesaro@gmail.com"


class TestStringEqual(unittest.TestCase):
    """BNF Checker"""
    def testBasic(self):
        self.assertTrue(equal(String('a'), 'a', 'a'))

# Path: pydsl/equal.py
# def equal_factory(definition):
#     from pydsl.grammar.definition import String
#     if isinstance(definition, String):
#         return lambda x,y: x==y
# 
# def equal(definition, first_element, second_element) -> bool:
#     """Compares if the two elements are equal according to the grammar definition"""
#     if not check(definition, first_element):
#         raise ValueError
#     if not check(definition, second_element):
#         raise ValueError
#     equal_checker = equal_factory(definition)
#     return equal_checker(first_element, second_element)
# 
# Path: pydsl/grammar/definition.py
# class String(Grammar, str):
#     def __init__(self, string):
#         if isinstance(string, list):
#             raise TypeError('Attempted to initialize a String with a list %s' % (string, ) )
#         Grammar.__init__(self, None)
# 
#     @property
#     def first(self):
#         return String(self[0])
# 
#     def enum(self):
#         yield self
# 
#     @property
#     def maxsize(self):
#         return len(self)
# 
#     @property
#     def minsize(self):
#         return len(self)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding


# Path: tests/unit/test_Equal.py
import unittest
from pydsl.equal import equal_factory, equal
from pydsl.grammar.definition import String

#!/usr/bin/env python
#This file is part of pydsl.
#
#pydsl is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with pydsl.  If not, see <http://www.gnu.org/licenses/>.

__author__ = "Nestor Arocha"
__copyright__ = "Copyright 2008-2020, Nestor Arocha"
__email__ = "nesaro@gmail.com"


class TestStringEqual(unittest.TestCase):
    """BNF Checker"""
    def testBasic(self):
        self.assertTrue(equal(String('a'), 'a', 'a'))

        self.assertRaises(ValueError, equal, String('a'), 'b', 'a')