File: test_grammar_jy.py

package info (click to toggle)
jython 2.5.1-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 41,624 kB
  • ctags: 101,579
  • sloc: python: 351,444; java: 204,338; xml: 1,316; sh: 330; ansic: 126; perl: 114; makefile: 94
file content (39 lines) | stat: -rw-r--r-- 980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
""" Extra grammar tests for Jython.
"""

from test import test_support
import unittest

class GrammarTest(unittest.TestCase):
    def test_triple_quote_len(self):
        s1 = r"""
        \""" 1.triple-quote
        \""" 2.triple-quote
        """

        s2 = r'''
        \""" 1.triple-quote
        \""" 2.triple-quote
        '''
        self.assert_(not '\r' in s1)
        self.assertEquals(len(s1), len(s2))

    def testStringPrefixes(self):
        self.assertEquals(u"spam",U"spam")
        self.assertEquals(r"spam", R"spam")
        self.assertEquals(uR"spam", Ur"spam")
        self.assertEquals(ur"spam", UR"spam")

    def testKeywordOperations(self):
        def foo(a=1, b=2 + 4):
            return b
        self.assertEquals(6, foo())
        self.assertEquals(6, foo(1))
        self.assertEquals(7, foo(1, 7))
        self.assertEquals(10, foo(b=10))

def test_main():
    test_support.run_unittest(GrammarTest)

if __name__ == '__main__':
    test_main()