Exemplo n.º 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")')
Exemplo n.º 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")')
Exemplo n.º 3
0
Arquivo: memo.py Projeto: 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))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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"]')
Exemplo n.º 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"]')
Exemplo n.º 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')
Exemplo n.º 9
0
def to_sexp(t):
    if hasattr(t, 'to_sexp'):
        return t.to_sexp()
    return sexpdata.tosexp(t, str_as='symbol')
Exemplo n.º 10
0
def check_identity(obj):
    eq_(parse(tosexp(obj))[0], obj)
Exemplo n.º 11
0
def test_tosexp_value_errors():
    tosexp((), tuple_as='')
    tosexp('', str_as='')
    tosexp(Parens())
Exemplo n.º 12
0
def check_identity(obj):
    eq_(parse(tosexp(obj))[0], obj)
Exemplo n.º 13
0
Arquivo: sqlio.py Projeto: knz/sqlexp
 def __repr__(self):
     return sexpdata.tosexp(dict(self))