patch 8.2.0610: some tests are still old style
Problem: Some tests are still old style.
Solution: Convert to new style tests. (Yegappan Lakshmanan, closes #5957)
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 9db1035..c6d6885 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -32,6 +32,7 @@
call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[0:8])
call assert_equal([], l[8:-1])
call assert_equal([], l[0:-10])
+ call assert_equal([], test_null_list()[:2])
endfunc
" List identity
@@ -168,6 +169,19 @@
call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d)
call filter(d, 'v:key =~ ''[ac391]''')
call assert_equal({'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}, d)
+
+ " duplicate key
+ call assert_fails("let d = {'k' : 10, 'k' : 20}", 'E721:')
+ " missing comma
+ call assert_fails("let d = {'k' : 10 'k' : 20}", 'E722:')
+ " missing curly brace
+ call assert_fails("let d = {'k' : 10,", 'E723:')
+ " invalid key
+ call assert_fails('let d = #{++ : 10}', 'E15:')
+ " wrong type for key
+ call assert_fails('let d={[] : 10}', 'E730:')
+ " undefined variable as value
+ call assert_fails("let d={'k' : i}", 'E121:')
endfunc
" Dictionary identity
@@ -262,7 +276,7 @@
unlet g:dict
endfunc
-" Test removing items in la dictionary
+" Test removing items in a dictionary
func Test_dict_func_remove()
let d = {1:'a', 2:'b', 3:'c'}
call assert_equal('b', remove(d, 2))
@@ -634,6 +648,11 @@
call assert_fails('call reverse("")', 'E899:')
call assert_fails('call uniq([1, 2], {x, y -> []})', 'E882:')
+ call assert_fails("call sort([1, 2], function('min'), 1)", "E715:")
+ call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:")
+ call assert_fails("call sort([1, 2], function('min'))", "E702:")
+ call assert_equal(0, sort(test_null_list()))
+ call assert_equal(0, uniq(test_null_list()))
endfunc
" splitting a string to a List using split()
@@ -748,6 +767,9 @@
call assert_fails("call extend([1, 2], 1)", 'E712:')
call assert_fails("call extend([1, 2], {})", 'E712:')
+
+ " Extend g: dictionary with an invalid variable name
+ call assert_fails("call extend(g:, {'-!' : 10})", 'E461:')
endfunc
func s:check_scope_dict(x, fixed)
@@ -871,6 +893,26 @@
call assert_fails("let v = range(5)[2:[]]", 'E730:')
call assert_fails("let v = range(5)[2:{-> 2}(]", 'E116:')
call assert_fails("let v = range(5)[2:3", 'E111:')
+ call assert_fails("let l = insert([1,2,3], 4, 10)", 'E684:')
+ call assert_fails("let l = insert([1,2,3], 4, -10)", 'E684:')
+ call assert_fails("let l = insert([1,2,3], 4, [])", 'E745:')
+endfunc
+
+" Test for a null list
+func Test_null_list()
+ call assert_equal(0, join(test_null_list()))
+ call assert_fails('let s = join([1, 2], [])', 'E730:')
+ call assert_equal([], split(test_null_string()))
+endfunc
+
+" Test for a null dict
+func Test_null_dict()
+ call assert_equal(0, items(test_null_dict()))
+ call assert_equal(0, keys(test_null_dict()))
+ call assert_equal(0, values(test_null_dict()))
+ call assert_false(has_key(test_null_dict(), 'k'))
+ call assert_fails("let l = [] + test_null_list()", 'E15:')
+ call assert_fails("let l = test_null_list() + []", 'E15:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab