summaryrefslogtreecommitdiff
path: root/src/testdir/test49.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test49.vim')
-rw-r--r--src/testdir/test49.vim501
1 files changed, 3 insertions, 498 deletions
diff --git a/src/testdir/test49.vim b/src/testdir/test49.vim
index df2f3c994..5973b1c5b 100644
--- a/src/testdir/test49.vim
+++ b/src/testdir/test49.vim
@@ -1,6 +1,6 @@
" Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
-" Last Change: 2015 Dec 30
+" Last Change: 2016 Jan 02
"-------------------------------------------------------------------------------
" Test environment {{{1
@@ -608,503 +608,8 @@ com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)
" END_OF_TEST_ENVIRONMENT - do not change or remove this line.
-" Tests 1 to 6 were moved to test_viml.vim
-let Xtest = 7
-
-"-------------------------------------------------------------------------------
-" Test 7: Continuing on errors outside functions {{{1
-"
-" On an error outside a function, the script processing continues
-" at the line following the outermost :endif or :endwhile. When not
-" inside an :if or :while, the script processing continues at the next
-" line.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-if 1
- Xpath 1 " X: 1
- while 1
- Xpath 2 " X: 2
- asdf
- Xpath 4 " X: 0
- break
- endwhile | Xpath 8 " X: 0
- Xpath 16 " X: 0
-endif | Xpath 32 " X: 0
-Xpath 64 " X: 64
-
-while 1
- Xpath 128 " X: 128
- if 1
- Xpath 256 " X: 256
- asdf
- Xpath 512 " X: 0
- endif | Xpath 1024 " X: 0
- Xpath 2048 " X: 0
- break
-endwhile | Xpath 4096 " X: 0
-Xpath 8192 " X: 8192
-
-asdf
-Xpath 16384 " X: 16384
-
-asdf | Xpath 32768 " X: 0
-Xpath 65536 " X: 65536
-
-Xcheck 90563
-
-
-"-------------------------------------------------------------------------------
-" Test 8: Aborting and continuing on errors inside functions {{{1
-"
-" On an error inside a function without the "abort" attribute, the
-" script processing continues at the next line (unless the error was
-" in a :return command). On an error inside a function with the
-" "abort" attribute, the function is aborted and the script processing
-" continues after the function call; the value -1 is returned then.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-function! F()
- if 1
- Xpath 1 " X: 1
- while 1
- Xpath 2 " X: 2
- asdf
- Xpath 4 " X: 4
- asdf | Xpath 8 " X: 0
- Xpath 16 " X: 16
- break
- endwhile
- Xpath 32 " X: 32
- endif | Xpath 64 " X: 64
- Xpath 128 " X: 128
-
- while 1
- Xpath 256 " X: 256
- if 1
- Xpath 512 " X: 512
- asdf
- Xpath 1024 " X: 1024
- asdf | Xpath 2048 " X: 0
- Xpath 4096 " X: 4096
- endif
- Xpath 8192 " X: 8192
- break
- endwhile | Xpath 16384 " X: 16384
- Xpath 32768 " X: 32768
-
- return novar " returns (default return value 0)
- Xpath 65536 " X: 0
- return 1 " not reached
-endfunction
-
-function! G() abort
- if 1
- Xpath 131072 " X: 131072
- while 1
- Xpath 262144 " X: 262144
- asdf " returns -1
- Xpath 524288 " X: 0
- break
- endwhile
- Xpath 1048576 " X: 0
- endif | Xpath 2097152 " X: 0
- Xpath Xpath 4194304 " X: 0
-
- return -4 " not reached
-endfunction
-
-function! H() abort
- while 1
- Xpath 8388608 " X: 8388608
- if 1
- Xpath 16777216 " X: 16777216
- asdf " returns -1
- Xpath 33554432 " X: 0
- endif
- Xpath 67108864 " X: 0
- break
- endwhile | Xpath 134217728 " X: 0
- Xpath 268435456 " X: 0
-
- return -4 " not reached
-endfunction
-
-" Aborted functions (G and H) return -1.
-let sum = (F() + 1) - 4*G() - 8*H()
-Xpath 536870912 " X: 536870912
-if sum != 13
- Xpath 1073741824 " X: 0
- Xout "sum is" sum
-endif
-
-unlet sum
-delfunction F
-delfunction G
-delfunction H
-
-Xcheck 562493431
-
-
-"-------------------------------------------------------------------------------
-" Test 9: Continuing after aborted functions {{{1
-"
-" When a function with the "abort" attribute is aborted due to an
-" error, the next function back in the call hierarchy without an
-" "abort" attribute continues; the value -1 is returned then.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-function! F() abort
- Xpath 1 " X: 1
- let result = G() " not aborted
- Xpath 2 " X: 2
- if result != 2
- Xpath 4 " X: 0
- endif
- return 1
-endfunction
-
-function! G() " no abort attribute
- Xpath 8 " X: 8
- if H() != -1 " aborted
- Xpath 16 " X: 0
- endif
- Xpath 32 " X: 32
- return 2
-endfunction
-
-function! H() abort
- Xpath 64 " X: 64
- call I() " aborted
- Xpath 128 " X: 0
- return 4
-endfunction
-
-function! I() abort
- Xpath 256 " X: 256
- asdf " error
- Xpath 512 " X: 0
- return 8
-endfunction
-
-if F() != 1
- Xpath 1024 " X: 0
-endif
-
-delfunction F
-delfunction G
-delfunction H
-delfunction I
-
-Xcheck 363
-
-
-"-------------------------------------------------------------------------------
-" Test 10: :if, :elseif, :while argument parsing {{{1
-"
-" A '"' or '|' in an argument expression must not be mixed up with
-" a comment or a next command after a bar. Parsing errors should
-" be recognized.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-function! MSG(enr, emsg)
- let english = v:lang == "C" || v:lang =~ '^[Ee]n'
- if a:enr == ""
- Xout "TODO: Add message number for:" a:emsg
- let v:errmsg = ":" . v:errmsg
- endif
- let match = 1
- if v:errmsg !~ '^'.a:enr.':' || (english && v:errmsg !~ a:emsg)
- let match = 0
- if v:errmsg == ""
- Xout "Message missing."
- else
- let v:errmsg = escape(v:errmsg, '"')
- Xout "Unexpected message:" v:errmsg
- endif
- endif
- return match
-endfunction
-
-if 1 || strlen("\"") | Xpath 1 " X: 1
- Xpath 2 " X: 2
-endif
-Xpath 4 " X: 4
-
-if 0
-elseif 1 || strlen("\"") | Xpath 8 " X: 8
- Xpath 16 " X: 16
-endif
-Xpath 32 " X: 32
-
-while 1 || strlen("\"") | Xpath 64 " X: 64
- Xpath 128 " X: 128
- break
-endwhile
-Xpath 256 " X: 256
-
-let v:errmsg = ""
-if 1 ||| strlen("\"") | Xpath 512 " X: 0
- Xpath 1024 " X: 0
-endif
-Xpath 2048 " X: 2048
-if !MSG('E15', "Invalid expression")
- Xpath 4096 " X: 0
-endif
-
-let v:errmsg = ""
-if 0
-elseif 1 ||| strlen("\"") | Xpath 8192 " X: 0
- Xpath 16384 " X: 0
-endif
-Xpath 32768 " X: 32768
-if !MSG('E15', "Invalid expression")
- Xpath 65536 " X: 0
-endif
-
-let v:errmsg = ""
-while 1 ||| strlen("\"") | Xpath 131072 " X: 0
- Xpath 262144 " X: 0
- break
-endwhile
-Xpath 524288 " X: 524288
-if !MSG('E15', "Invalid expression")
- Xpath 1048576 " X: 0
-endif
-
-delfunction MSG
-
-Xcheck 559615
-
-
-"-------------------------------------------------------------------------------
-" Test 11: :if, :elseif, :while argument evaluation after abort {{{1
-"
-" When code is skipped over due to an error, the boolean argument to
-" an :if, :elseif, or :while must not be evaluated.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-let calls = 0
-
-function! P(num)
- let g:calls = g:calls + a:num " side effect on call
- return 0
-endfunction
-
-if 1
- Xpath 1 " X: 1
- asdf " error
- Xpath 2 " X: 0
- if P(1) " should not be called
- Xpath 4 " X: 0
- elseif !P(2) " should not be called
- Xpath 8 " X: 0
- else
- Xpath 16 " X: 0
- endif
- Xpath 32 " X: 0
- while P(4) " should not be called
- Xpath 64 " X: 0
- endwhile
- Xpath 128 " X: 0
-endif
-
-if calls % 2
- Xpath 256 " X: 0
-endif
-if (calls/2) % 2
- Xpath 512 " X: 0
-endif
-if (calls/4) % 2
- Xpath 1024 " X: 0
-endif
-Xpath 2048 " X: 2048
-
-unlet calls
-delfunction P
-
-Xcheck 2049
-
-
-"-------------------------------------------------------------------------------
-" Test 12: Expressions in braces in skipped code {{{1
-"
-" In code skipped over due to an error or inactive conditional,
-" an expression in braces as part of a variable or function name
-" should not be evaluated.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-XloopINIT 1 8
-
-function! NULL()
- Xloop 1 " X: 0
- return 0
-endfunction
-
-function! ZERO()
- Xloop 2 " X: 0
- return 0
-endfunction
-
-function! F0()
- Xloop 4 " X: 0
-endfunction
-
-function! F1(arg)
- Xpath 4096 " X: 0
-endfunction
-
-let V0 = 1
-
-Xpath 8192 " X: 8192
-echo 0 ? F{NULL() + V{ZERO()}}() : 1
-XloopNEXT
-
-Xpath 16384 " X: 16384
-if 0
- Xpath 32768 " X: 0
- call F{NULL() + V{ZERO()}}()
-endif
-XloopNEXT
-
-Xpath 65536 " X: 65536
-if 1
- asdf " error
- Xpath 131072 " X: 0
- call F1(F{NULL() + V{ZERO()}}())
-endif
-XloopNEXT
-
-Xpath 262144 " X: 262144
-if 1
- asdf " error
- Xpath 524288 " X: 0
- call F{NULL() + V{ZERO()}}()
-endif
-
-Xcheck 352256
-
-
-"-------------------------------------------------------------------------------
-" Test 13: Failure in argument evaluation for :while {{{1
-"
-" A failure in the expression evaluation for the condition of a :while
-" causes the whole :while loop until the matching :endwhile being
-" ignored. Continuation is at the next following line.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-
-Xpath 1 " X: 1
-while asdf
- Xpath 2 " X: 0
- while 1
- Xpath 4 " X: 0
- break
- endwhile
- Xpath 8 " X: 0
- break
-endwhile
-Xpath 16 " X: 16
-
-while asdf | Xpath 32 | endwhile | Xpath 64 " X: 0
-Xpath 128 " X: 128
-
-Xcheck 145
-
-
-"-------------------------------------------------------------------------------
-" Test 14: Failure in argument evaluation for :if {{{1
-"
-" A failure in the expression evaluation for the condition of an :if
-" does not cause the corresponding :else or :endif being matched to
-" a previous :if/:elseif. Neither of both branches of the failed :if
-" are executed.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-XloopINIT 1 256
-
-function! F()
- Xloop 1 " X: 1 + 256 * 1
- let x = 0
- if x " false
- Xloop 2 " X: 0 + 256 * 0
- elseif !x " always true
- Xloop 4 " X: 4 + 256 * 4
- let x = 1
- if g:boolvar " possibly undefined
- Xloop 8 " X: 8 + 256 * 0
- else
- Xloop 16 " X: 0 + 256 * 0
- endif
- Xloop 32 " X: 32 + 256 * 32
- elseif x " never executed
- Xloop 64 " X: 0 + 256 * 0
- endif
- Xloop 128 " X: 128 + 256 * 128
-endfunction
-
-let boolvar = 1
-call F()
-
-XloopNEXT
-unlet boolvar
-call F()
-
-delfunction F
-
-Xcheck 42413
-
-
-"-------------------------------------------------------------------------------
-" Test 15: Failure in argument evaluation for :if (bar) {{{1
-"
-" Like previous test, except that the failing :if ... | ... | :endif
-" is in a single line.
-"-------------------------------------------------------------------------------
-
-XpathINIT
-XloopINIT 1 256
-
-function! F()
- Xloop 1 " X: 1 + 256 * 1
- let x = 0
- if x " false
- Xloop 2 " X: 0 + 256 * 0
- elseif !x " always true
- Xloop 4 " X: 4 + 256 * 4
- let x = 1
- if g:boolvar | Xloop 8 | else | Xloop 16 | endif " X: 8
- Xloop 32 " X: 32 + 256 * 32
- elseif x " never executed
- Xloop 64 " X: 0 + 256 * 0
- endif
- Xloop 128 " X: 128 + 256 * 128
-endfunction
-
-let boolvar = 1
-call F()
-
-XloopNEXT
-unlet boolvar
-call F()
-
-delfunction F
-
-Xcheck 42413
-
+" Tests 1 to 15 were moved to test_viml.vim
+let Xtest = 16
"-------------------------------------------------------------------------------
" Test 16: Double :else or :elseif after :else {{{1