summaryrefslogtreecommitdiff
path: root/src/testdir/test87.in
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-05-21 20:40:40 +0200
committerBram Moolenaar <Bram@vim.org>2013-05-21 20:40:40 +0200
commita7b64ce74e857d4516b87ca80c850e5ef6324ba6 (patch)
tree7973c8efc51c8f261a01aa5c19d519b2c643233d /src/testdir/test87.in
parentcac867ad1836d0bc44403f66a3367afffda76095 (diff)
downloadvim-git-a7b64ce74e857d4516b87ca80c850e5ef6324ba6.tar.gz
updated for version 7.3.997v7.3.997
Problem: Vim and Python exceptions are different. Solution: Make Vim exceptions be Python exceptions. (ZyX)
Diffstat (limited to 'src/testdir/test87.in')
-rw-r--r--src/testdir/test87.in56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/testdir/test87.in b/src/testdir/test87.in
index 94c1ab535..69af02eec 100644
--- a/src/testdir/test87.in
+++ b/src/testdir/test87.in
@@ -367,20 +367,24 @@ def e(s, g=globals(), l=locals()):
try:
exec(s, g, l)
except Exception as e:
- vim.command('throw ' + repr(e.__class__.__name__))
+ vim.command('return ' + repr(e.__class__.__name__))
def ev(s, g=globals(), l=locals()):
try:
return eval(s, g, l)
except Exception as e:
- vim.command('throw ' + repr(e.__class__.__name__))
+ vim.command('let exc=' + repr(e.__class__.__name__))
return 0
EOF
:function E(s)
: python3 e(vim.eval('a:s'))
:endfunction
:function Ev(s)
-: return py3eval('ev(vim.eval("a:s"))')
+: let r=py3eval('ev(vim.eval("a:s"))')
+: if exists('exc')
+: throw exc
+: endif
+: return r
:endfunction
:py3 gopts1=vim.options
:py3 wopts1=vim.windows[2].options
@@ -424,27 +428,24 @@ EOF
: catch
: put =' p/'.v.'! '.v:exception
: endtry
-: try
-: call E(v.'["'.oname.'"]=invval')
-: catch
-: put =' inv: '.string(invval).'! '.v:exception
-: endtry
+: let r=E(v.'['''.oname.''']=invval')
+: if r isnot 0
+: put =' inv: '.string(invval).'! '.r
+: endif
: for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3'])
: let val=substitute(vv, '^.opts', 'oval', '')
-: try
-: call E(vv.'["'.oname.'"]='.val)
-: catch
-: put =' '.vv.'! '.v:exception
-: endtry
+: let r=E(vv.'['''.oname.''']='.val)
+: if r isnot 0
+: put =' '.vv.'! '.r
+: endif
: endfor
: endfor
: call RecVars(oname)
: for v in ['wopts3', 'bopts3']
-: try
-: call E('del '.v.'["'.oname.'"]')
-: catch
-: put =' del '.v.'! '.v:exception
-: endtry
+: let r=E('del '.v.'["'.oname.'"]')
+: if r isnot 0
+: put =' del '.v.'! '.r
+: endif
: endfor
: call RecVars(oname)
:endfor
@@ -638,6 +639,25 @@ for expr, attr in (
):
cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
EOF
+:"
+:" Test exceptions
+:fun Exe(e)
+: execute a:e
+:endfun
+py3 << EOF
+def ee(expr, g=globals(), l=locals()):
+ try:
+ exec(expr, g, l)
+ except Exception as e:
+ cb.append(repr((e.__class__, e)))
+Exe = vim.bindeval('function("Exe")')
+ee('vim.command("throw \'abc\'")')
+ee('Exe("throw \'def\'")')
+ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")')
+ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")')
+ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")')
+ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")')
+EOF
:endfun
:"
:call Test()