# This program 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 2 of the License, or (at your option) any later
# version.
#
# This program 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
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
""" Copyright (c) 2000-2003 LOGILAB S.A. (Paris, FRANCE).
 http://www.logilab.fr/ -- mailto:contact@logilab.fr

Check format checker helper functions
"""

__revision__ = '$Id: test_format.py,v 1.13 2005-11-02 09:22:06 syt Exp $'

import unittest
import sys
import re
from os import linesep

from pylint.checkers.format import *
from utils import TestReporter

REPORTER = TestReporter()

class StringRgxTest(unittest.TestCase):
    """test the STRING_RGX regular expression"""
    
    def test_known_values_1(self):
        self.assertEqual(STRING_RGX.sub('', '"yo"'), '')
        
    def test_known_values_2(self):
        self.assertEqual(STRING_RGX.sub('', "'yo'"), '')
        
    def test_known_values_tq_1(self):
        self.assertEqual(STRING_RGX.sub('', '"""yo"""'), '')
        
    def test_known_values_tq_2(self):
        self.assertEqual(STRING_RGX.sub('', '"""yo\n"""'), '')
        
    def test_known_values_ta_1(self):
        self.assertEqual(STRING_RGX.sub('', "'''yo'''"), '')
        
    def test_known_values_ta_2(self):
        self.assertEqual(STRING_RGX.sub('', "'''yo\n'''"), '')
        
    def test_known_values_5(self):
        self.assertEqual(STRING_RGX.sub('', r'"yo\"yo"'), '')
        
    def test_known_values_6(self):
        self.assertEqual(STRING_RGX.sub('', r"'yo\'yo'"), '')
        
    def test_known_values_7(self):
        self.assertEqual(STRING_RGX.sub('', '"yo"upi"yo"upi'), 'upiupi')

    def test_known_values_8(self):
        self.assertEqual(STRING_RGX.sub('', r"'yo\'yo\''"), '')
        
    def test_known_values_9(self):
        self.assertEqual(STRING_RGX.sub('', r'"yoyo\""'), '')

    def test_known_values_10(self):
        self.assertEqual(STRING_RGX.sub('', 'self.filterFunc = eval(\'lambda %s: %s\'%(\',\'.join(variables),formula),{},{})'),
                         'self.filterFunc = eval(%(.join(variables),formula),{},{})')
        
    def test_known_values_11(self):
        self.assertEqual(STRING_RGX.sub('', 'cond_list[index] = OLD_PROG.sub(r\'getattr(__old__,"\1")\',cond)'),
                         'cond_list[index] = OLD_PROG.sub(r,cond)')


##     def test_no_crash(self):
##         crash_str = """wizardBmp = ('eJzdXc2R5DxyPZBR0WPBd+4rywOZsQasCevDHHTVdQ5jx1w3QnJBF7mwISdUUyAeXv4CIFndPYpA\ndLBR+H14TCQyAfDHf/7vcvu+h7ef7TkKI2leEU7WW7K//3r8vf/jn78f3n9tf/+f3w9vPx8P+zMi\n3389kpWUj7/8a3lWkSUll/NDAYv2lwc3huPLw1XPF4JsCmxQPJEEaMAZCRg0HgU9IiY7gy+A/X8T\nAKnk2P1v/2ooPZ6B8CM9pWTiWdgthhbtPw9Yl6v2tZKQ/u7s3/7117/9twva+vZfO/Ge8LoEtrxV\nXLWRfxiwjJ78+8Cn4FmoWB5AUX6wHCsEBvKPv4/nndUmC1hdfuWUoYx1mcBksCKRH87Hx+E3bslP\nt++/iVeRVJACKyaeJbAFTbzg8Yi4kQD20bAS0No/KBSKtn+fHSyB/y3PJc0DWPzL6UtRKjGK5QdR\n/tvPUiB+3YE1YPK/zJkP+BvVruMLCeltLZElBgRGZMmFlFwOMxzlFOI9nguTS2I841euCA8A9tMp\ndz4wxxSjkpQq0s2r0nf/ZcZ+OiyzGIKr65MnJZ6nG6YTXlIbOGURvCoSNUIsc43lGZF4gLr16VgN\n4snPETntw7UNyCUwIiFjPx23PEAdUmyEcGMxuFZWd8u00tjNhZQQrYrSiET2PwXYSOi5M77i9mD5\ng2m4xqSELwWs2wyQihmrmFa09DXQClQAqVhmPp5zUcw66moYi2Qo8zewX1JxtfNsxEyXQonUdXWG\nKcYmCb6+jAV/mHjMMZa0KqXSYJWqwM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2yvj8WjGprxE19MZV2B1PEadHsnTeI6vWtXr/9mp2Y+HdUS6gaGzT10k3oNtnpWQmyQGK66\n5Gr+xxwWmSBjrG1z0qrxBgdDPASsymgdOrfvLEvbriH2FlmSq5j6dhSq71UbNFbeY2Aa0GesN7mI\nxFGW6G+PZioUu/FSPy4D0Yfn/YGoVeRqgRRu2fJQZnk44ttunLqvVbwd1QMu3LvgP6Vcq2Uy8nl9\nwcA9gs8UICy8E6bCxcj8dm4+c32rG3jWsmFDpcSWA0qpgHVrBLBoW8l+jSg4LI27BUoMMUc3xnIk\n8dCSijc1NWBl4dj+YYHdf72Rt7d+m6zIBMVt9nl9heWAUr93RfTNOTDoaPIycXswu14hbFGIFpKy\nFq56UXYV8u80VnhGmE/H1q29SNpOxpt2rIvN2z3j0mIOZnYt5Alu41+g+9zwkUvaS4IrChbrBfs8\n8I9Z7RCgHhwD9vAe/rZhw7i5xfxlFa3Lg9LH5Jvbb4MXuZKE5DMjTqVek/zax/rifhKlTKDtJ3ou\nWxFe9VwrKjGIV//mLYQa6ZY82KSSXmVXDdDtkTH/ByrXy2U=\n', (115, 260), None)"""
##         re.sub(SQSTRING_RGX, '', crash_str)
##         re.sub(TQSTRING_RGX, '', crash_str)
##         re.sub(SASTRING_RGX, '', crash_str)
##         re.sub(TASTRING_RGX, '', crash_str)
        

if linesep != '\n':
    LINE_RGX = re.compile(linesep)
    def ulines(strings):
        return strings[0], LINE_RGX.sub('\n', strings[1])
else:
    def ulines(strings):
        return strings
    
class ChecklineFunctionTest(unittest.TestCase):
    """test the check_line method"""
    
    def test_known_values_opspace_1(self):
        self.assertEqual(ulines(check_line('a=1', REPORTER)), ('C0322', 'a=1\n ^'))
        
    def test_known_values_opspace_2(self):
        self.assertEqual(ulines(check_line('a= 1', REPORTER)), ('C0322', 'a= 1\n ^') )
        
    def test_known_values_opspace_3(self):
        self.assertEqual(ulines(check_line('a =1', REPORTER)), ('C0323', 'a =1\n  ^'))

    def test_known_values_opspace_4(self):
        self.assertEqual(check_line('f(a=1)', REPORTER), None)

    def test_known_values_opspace_4(self):
        self.assertEqual(check_line('f(a=1)', REPORTER), None)

        
##     def test_known_values_colonnl_1(self):
##         self.assertEqual(check_line('if a: a = 1', REPORTER),
##                          ('W0321', 'if a: a = 1\n    ^^^^^^^'))
        
##     def test_known_values_colonnl_2(self):
##         self.assertEqual(check_line('a[:1]', REPORTER), None)
        
##     def test_known_values_colonnl_3(self):
##         self.assertEqual(check_line('a[1:]', REPORTER), None)
        
##     def test_known_values_colonnl_4(self):
##         self.assertEqual(check_line('a[1:2]', REPORTER), None)

##     def test_known_values_colonnl_5(self):
##         self.assertEqual(check_line('def intersection(list1, list2):', REPORTER), None)

##     def test_known_values_colonnl_6(self):
##         self.assertEqual(check_line('def intersection(list1, list2):\n', REPORTER), None)

##     def test_known_values_colonnl_7(self):
##         self.assertEqual(check_line('if file[:pfx_len] == path:\n', REPORTER), None)

##     def test_known_values_colonnl_8(self):
##         self.assertEqual(check_line('def intersection(list1, list2): pass\n', REPORTER),
##                          ('W0321',
## 'def intersection(list1, list2): pass\n                              ^^^^^^') )

##     def test_known_values_colonnl_9(self):
##         self.assertEqual(check_line('if file[:pfx_len[1]] == path:\n', REPORTER), None)

##     def test_known_values_colonnl_10(self):
##         self.assertEqual(check_line('if file[pfx_len[1]] == path:\n', REPORTER), None)

        
    def test_known_values_commaspace_1(self):
        self.assertEqual(ulines(check_line('a, b = 1,2', REPORTER)),
                         ('C0324', 'a, b = 1,2\n        ^^'))

        
    def test_known_values_instring_1(self):
        self.assertEqual(check_line('f("a=1")', REPORTER), None)
        
    def test_known_values_instring_2(self):
        self.assertEqual(ulines(check_line('print >>1, ("a:1")', REPORTER)),
                         ('C0323', 'print >>1, ("a:1")\n       ^'))

    def test_known_values_all_1(self):
        self.assertEqual(ulines(check_line("self.filterFunc = eval('lambda %s: %s'%(','.join(variables),formula),{},{})", REPORTER)),
                         ('C0324', "self.filterFunc = eval('lambda %s: %s'%(','.join(variables),formula),{},{})\n                                                           ^^"))

    def test_known_values_tqstring(self):
        self.assertEqual(check_line('print """<a="=")\n"""', REPORTER), None)
        
    def test_known_values_tastring(self):
        self.assertEqual(check_line("print '''<a='=')\n'''", REPORTER), None)
        
if __name__ == '__main__':
    unittest.main()
