コード例 #1
0
ファイル: test_sexpdata.py プロジェクト: EdTsft/sexpdata
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
ファイル: test_sexpdata.py プロジェクト: EdTsft/sexpdata
        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
ファイル: test_sexpdata.py プロジェクト: EdTsft/sexpdata
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
ファイル: test_sexpdata.py プロジェクト: s-zeng/sexpdata
def test_tosexp_value_errors():
    tosexp((), tuple_as='')
    tosexp('', str_as='')
    tosexp(Parens())
コード例 #12
0
ファイル: test_sexpdata.py プロジェクト: EdTsft/sexpdata
def check_identity(obj):
    eq_(parse(tosexp(obj))[0], obj)
コード例 #13
0
ファイル: sqlio.py プロジェクト: knz/sqlexp
 def __repr__(self):
     return sexpdata.tosexp(dict(self))