1
0
forked from aniani/vim

updated for version 7.0042

This commit is contained in:
Bram Moolenaar
2005-01-19 22:18:32 +00:00
parent c92ad2e2c2
commit 383f9bc302
34 changed files with 463 additions and 56 deletions

View File

@@ -23,7 +23,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test33.out test34.out test35.out test36.out test37.out \
test38.out test39.out test40.out test41.out test42.out \
test43.out test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out
test48.out test51.out test53.out test54.out test55.out
.SUFFIXES: .in .out
@@ -97,3 +97,4 @@ test48.out: test48.in
test51.out: test51.in
test53.out: test53.in
test54.out: test54.in
test55.out: test55.in

View File

@@ -17,7 +17,7 @@ SCRIPTS16 = test1.out test19.out test20.out test22.out \
test23.out test24.out test28.out test29.out \
test35.out test36.out test43.out \
test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out
test48.out test51.out test53.out test54.out test55.out
SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test8.out test9.out test11.out test13.out test14.out \

View File

@@ -23,7 +23,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test33.out test34.out test35.out test36.out test37.out \
test38.out test39.out test40.out test41.out test42.out \
test43.out test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out
test48.out test51.out test53.out test54.out test55.out
.SUFFIXES: .in .out

View File

@@ -1,6 +1,6 @@
" Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
" Last Change: 2005 Jan 16
" Last Change: 2005 Jan 18
"-------------------------------------------------------------------------------
" Test environment {{{1
@@ -8314,6 +8314,7 @@ if ExtraVim()
else
let v:errmsg = escape(v:errmsg, '"')
Xout "Expr" a:n.": Unexpected message:" v:errmsg
Xout "Expected: " . a:enr . ': ' . a:emsg
let g:taken = g:taken . "X"
endif
endif
@@ -8377,7 +8378,7 @@ if ExtraVim()
call MSG(t, 'E15', "Invalid expression")
endif
else
if t == 2 || t == 4
if t <= 2 || t == 4 || t == 5 || t == 6 || t == 8
call MSG(t, 'E475', 'Invalid argument\>')
else
call MSG(t, 'E121', "Undefined variable")

156
src/testdir/test55.in Normal file
View File

@@ -0,0 +1,156 @@
Tests for List and Dictionary types. vim: set ft=vim :
STARTTEST
:so small.vim
:fun Test()
:" Creating List directly with different types
:let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
:$put =string(l)
:$put =string(l[-1])
:$put =string(l[-4])
:try
: $put =string(l[-5])
:catch
: $put =v:exception[:14]
:endtry
:"
:" List identity
:let ll = l
:let lx = copy(l)
:try
: $put =(l == ll) . (l isnot ll) . (l is ll) . (l == lx) . (l is lx) . (l isnot lx)
:catch
: $put =v:exception
:endtry
:"
:" Creating Dictionary directly with different types
:let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
:$put =string(d) . d.1
:$put =string(sort(keys(d)))
:$put =string(values(d))
:for [key, val] in items(d)
: $put =key . ':' . string(val)
: unlet key val
:endfor
:call extend(d, {3:33, 1:99})
:call extend(d, {'b':'bbb', 'c':'ccc'}, "keep")
:try
: call extend(d, {3:333,4:444}, "error")
:catch
: $put =v:exception[:15] . v:exception[-1:-1]
:endtry
:$put =string(d)
:call filter(d, 'v:key =~ ''[ac391]''')
:$put =string(d)
:"
:" Dictionary identity
:let dd = d
:let dx = copy(d)
:try
: $put =(d == dd) . (d isnot dd) . (d is dd) . (d == dx) . (d is dx) . (d isnot dx)
:catch
: $put =v:exception
:endtry
:"
:" Changing var type should fail
:try
: let d = []
:catch
: $put =v:exception[:14] . v:exception[-1:-1]
:endtry
:try
: let l = {}
:catch
: $put =v:exception[:14] . v:exception[-1:-1]
:endtry
:"
:" removing items with :unlet
:unlet l[2]
:$put =string(l)
:let l = range(8)
:unlet l[:3]
:unlet l[1:]
:$put =string(l)
:"
:unlet d.c
:unlet d[-1]
:$put =string(d)
:"
:" manipulating a big Dictionary
:let d = {}
:for i in range(15000)
: let d[i] = 30000 - i
:endfor
:$put =d[0] . ' ' . d[100] . ' ' . d[999] . ' ' . d[14000] . ' ' . d[14999]
:try
: let n = d[15000]
:catch
: $put =v:exception[:14] . v:exception[-5:-1]
:endtry
:" lookup each items
:for i in range(15000)
: if d[i] != 30000 - i
: $put =d[i]
: endif
:endfor
: let i += 1
:" delete even items
:while i >= 2
: let i -= 2
: unlet d[i]
:endwhile
:$put =get(d, 15000 - 100, 'NONE') . ' ' . d[1]
:" delete odd items, checking value, one intentionally wrong
:let d[33] = 999
:let i = 1
:while i < 15000
: if d[i] != 30000 - i
: $put =i . '=' . d[i]
: else
: unlet d[i]
: endif
: let i += 2
:endwhile
:$put =string(d) " must be almost empty now
:unlet d
:"
:" Dictionary function
:let dict = {}
:func dict.func(a) dict
: $put =a:a . len(self.data)
:endfunc
:let dict.data = [1,2,3]
:call dict.func("len: ")
:echo dict.func("again: ")
:try
: let Fn = dict.func
: call Fn('xxx')
:catch
: $put =v:exception[:15]
:endtry
:sleep 5
:"
:" Nasty: remove func from Dict that's being called (works)
:let d = {1:1}
:func d.func(a)
: return "a:". a:a
:endfunc
:$put = d.func(string(remove(d, 'func')))
:"
:" Nasty: deepcopy() dict that refers to itself (fails)
:let d = {1:1, 2:2}
:let l = [4, d, 6]
:let d[3] = l
:try
: let x = deepcopy(d)
:catch
: $put =v:exception[:14]
:endtry
:"
:endfun
:call Test()
:"
:/^start:/,$wq! test.out
ENDTEST
start:

31
src/testdir/test55.ok Normal file
View File

@@ -0,0 +1,31 @@
start:
[1, 'as''d', [1, 2, function('strlen')], {'a': 1}]
{'a': 1}
1
Vim(put):E684:
101101
{'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}asd
['-1', '1', 'b']
['asd', [1, 2, function('strlen')], {'a': 1}]
1:'asd'
b:[1, 2, function('strlen')]
-1:{'a': 1}
Vim(call):E737: 3
{'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}
{'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}
101101
Vim(let):E706: d
Vim(let):E706: l
[1, 'as''d', {'a': 1}]
[4]
{'1': 99, '3': 33}
30000 29900 29001 16000 15001
Vim(let):E716: 15000
NONE 29999
33=999
{'33': 999}
len: 3
again: 3
Vim(call):E725:
a:function('2')
Vim(let):E698: