예제 #1
0
def test_tosexp_str_as():
    yield (eq_, tosexp('a', str_as='symbol'), 'a')
    yield (eq_, tosexp(['a'], str_as='symbol'), '(a)')
    yield (eq_, tosexp('a'), '"a"')
    yield (eq_, tosexp(['a']), '("a")')
    yield (eq_, tosexp(Quoted('a')), '\'"a"')
    yield (eq_, tosexp(Quoted(['a']), str_as='symbol'), '\'(a)')
    yield (eq_, tosexp([Quoted('a')], str_as='symbol'), '(\'a)')
    yield (eq_, tosexp(Quoted('a'), str_as='symbol'), '\'a')
    yield (eq_, tosexp(Quoted(['a'])), '\'("a")')
    yield (eq_, tosexp([Quoted('a')]), '(\'"a")')
예제 #2
0
def test_tosexp_str_as():
    yield (eq_, tosexp('a', str_as='symbol'), 'a')
    yield (eq_, tosexp(['a'], str_as='symbol'), '(a)')
    yield (eq_, tosexp('a'), '"a"')
    yield (eq_, tosexp(['a']), '("a")')
    yield (eq_, tosexp(Quoted('a')), '\'"a"')
    yield (eq_, tosexp(Quoted(['a']), str_as='symbol'), '\'(a)')
    yield (eq_, tosexp([Quoted('a')], str_as='symbol'), '(\'a)')
    yield (eq_, tosexp(Quoted('a'), str_as='symbol'), '\'a')
    yield (eq_, tosexp(Quoted(['a'])), '\'("a")')
    yield (eq_, tosexp([Quoted('a')]), '(\'"a")')
예제 #3
0
파일: memo.py 프로젝트: knz/sqlexp
 def ps(exp):
     if exp.op == 'lit':
         return sexpdata.tosexp(exp.args[0])
     elif exp.op == 'var':
         return '(@%d %s)' % (i, exp.args[0])
     elif exp.op in ['apply', 'exists']:
         _printtree(indent, exp.args[0], m, buf)
         return sexpdata.tosexp(exp)
     else:
         return '(%s %s)' % (exp.op, ' '.join(
             _printscalar(indent, i, m, buf) for i in exp.args))
예제 #4
0
        def test_dump_raw_utf8(self):
            """
            Test that sexpdata supports dumping encoded (raw) string.

            See also: https://github.com/tkf/emacs-jedi/issues/43

            """
            ustr = self.ustr
            sexp = utf8('"{0}"').format(ustr)
            self.assertEqual(tosexp(ustr.encode('utf-8')), sexp)
예제 #5
0
        def test_dump_raw_utf8(self):
            """
            Test that sexpdata supports dumping encoded (raw) string.

            See also: https://github.com/tkf/emacs-jedi/issues/43

            """
            ustr = self.ustr
            sexp = utf8('"{0}"').format(ustr)
            self.assertEqual(tosexp(ustr.encode('utf-8')), sexp)
예제 #6
0
def test_tosexp_tuple_as():
    yield (eq_, tosexp(('a', 'b')), '("a" "b")')
    yield (eq_, tosexp(('a', 'b'), tuple_as='array'), '["a" "b"]')
    yield (eq_, tosexp([('a', 'b')]), '(("a" "b"))')
    yield (eq_, tosexp([('a', 'b')], tuple_as='array'), '(["a" "b"])')
    yield (eq_, tosexp(Quoted(('a', ))), '\'("a")')
    yield (eq_, tosexp(Quoted(('a', )), tuple_as='array'), '\'["a"]')
예제 #7
0
def test_tosexp_tuple_as():
    yield (eq_, tosexp(('a', 'b')), '("a" "b")')
    yield (eq_, tosexp(('a', 'b'), tuple_as='array'), '["a" "b"]')
    yield (eq_, tosexp([('a', 'b')]), '(("a" "b"))')
    yield (eq_, tosexp([('a', 'b')], tuple_as='array'), '(["a" "b"])')
    yield (eq_, tosexp(Quoted(('a',))), '\'("a")')
    yield (eq_, tosexp(Quoted(('a',)), tuple_as='array'), '\'["a"]')
예제 #8
0
 def to_sexp(self):
     sexp = [[
         "caller",
         [["name", "\"{}\"".format(self.caller.name)],
          ["range", self.caller.range]]
     ],
             [
                 "inline",
                 [["name", "\"{}\"".format(self.inline.name)],
                  ["range", self.inline.range]]
             ],
             [
                 "callees",
                 [["ranges", [callee.range for callee in self.callees]]]
             ]]
     return sexpdata.tosexp(sexp, str_as='symbol')
예제 #9
0
def to_sexp(t):
    if hasattr(t, 'to_sexp'):
        return t.to_sexp()
    return sexpdata.tosexp(t, str_as='symbol')
예제 #10
0
def check_identity(obj):
    eq_(parse(tosexp(obj))[0], obj)
예제 #11
0
def test_tosexp_value_errors():
    tosexp((), tuple_as='')
    tosexp('', str_as='')
    tosexp(Parens())
예제 #12
0
def check_identity(obj):
    eq_(parse(tosexp(obj))[0], obj)
예제 #13
0
파일: sqlio.py 프로젝트: knz/sqlexp
 def __repr__(self):
     return sexpdata.tosexp(dict(self))