diff options
Diffstat (limited to 'src/testdir/test_blob.vim')
-rw-r--r-- | src/testdir/test_blob.vim | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim index 69c86963cd..e8bc2c9dad 100644 --- a/src/testdir/test_blob.vim +++ b/src/testdir/test_blob.vim @@ -1,6 +1,6 @@ " Tests for the Blob types -source vim9.vim +import './vim9.vim' as v9 func TearDown() " Run garbage collection after every test @@ -39,7 +39,7 @@ func Test_blob_create() call assert_equal(0, len(test_null_blob())) call assert_equal(0z, copy(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " assignment to a blob @@ -75,49 +75,49 @@ func Test_blob_assign() VAR m = deepcopy(l) LET m[0] = 0z34 #" E742 or E741 should not occur. END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0zDEADBEEF LET b[2 : 3] = 0z112233 END - call CheckLegacyAndVim9Failure(lines, 'E972:') + call v9.CheckLegacyAndVim9Failure(lines, 'E972:') let lines =<< trim END VAR b = 0zDEADBEEF LET b[2 : 3] = 0z11 END - call CheckLegacyAndVim9Failure(lines, 'E972:') + call v9.CheckLegacyAndVim9Failure(lines, 'E972:') let lines =<< trim END VAR b = 0zDEADBEEF LET b[3 : 2] = 0z END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF LET b ..= 0z33 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b ..= "xx" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b += "xx" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b[1 : 1] ..= 0z55 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) endfunc func Test_blob_get_range() @@ -133,7 +133,7 @@ func Test_blob_get_range() call assert_equal(0z, b[5 : 6]) call assert_equal(0z0011, b[-10 : 1]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " legacy script white space let b = 0z0011223344 @@ -158,19 +158,19 @@ func Test_blob_get() call assert_equal(0x44, b[4]) call assert_equal(0x44, b[-1]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z0011223344 echo b[5] END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0z0011223344 echo b[-8] END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_to_string() @@ -184,7 +184,7 @@ func Test_blob_to_string() call assert_equal('0z', string(b)) call assert_equal('0z', string(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_compare() @@ -211,54 +211,54 @@ func Test_blob_compare() call assert_false(b1 is b2) call assert_true(b1 isnot b2) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b1 = 0z0011 echo b1 == 9 END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) let lines =<< trim END VAR b1 = 0z0011 echo b1 != 9 END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 > b2 END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 < b2 END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 - b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 / b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 * b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) endfunc func Test_blob_index_assign() @@ -268,19 +268,19 @@ func Test_blob_index_assign() LET b[2] = 0x22 call assert_equal(0z001122, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z00 LET b[2] = 0x33 END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0z00 LET b[-2] = 0x33 END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_for_loop() @@ -313,7 +313,7 @@ func Test_blob_for_loop() endfor call assert_equal(5, i) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_concatenate() @@ -325,19 +325,19 @@ func Test_blob_concatenate() LET b = 0zDEAD + 0zBEEF call assert_equal(0zDEADBEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z0011 LET b += "a" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) let lines =<< trim END VAR b = 0z0011 LET b += 88 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) endfunc func Test_blob_add() @@ -346,7 +346,7 @@ func Test_blob_add() call add(b, 0x22) call assert_equal(0z001122, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Only works in legacy script let b = 0z0011 @@ -358,18 +358,18 @@ func Test_blob_add() VAR b = 0z0011 call add(b, [9]) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:']) let lines =<< trim END VAR b = 0z0011 call add("", 0x01) END - call CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:']) let lines =<< trim END add(test_null_blob(), 0x22) END - call CheckDefExecAndScriptFailure(lines, 'E1131:') + call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') let lines =<< trim END let b = 0zDEADBEEF @@ -377,7 +377,7 @@ func Test_blob_add() call add(b, 0) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_empty() @@ -411,32 +411,32 @@ func Test_blob_func_remove() call assert_equal(0zADBE, remove(b, 1, 2)) call assert_equal(0zDEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test invalid cases let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 5) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 1, 5) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 3, 2) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(test_null_blob(), 1, 2) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END let b = 0zDEADBEEF @@ -444,7 +444,7 @@ func Test_blob_func_remove() call remove(b, 0) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') " can only check at script level, not in a :def function let lines =<< trim END @@ -453,7 +453,7 @@ func Test_blob_func_remove() lockvar b remove(b, 0) END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') call assert_fails('echo remove(0z1020, [])', 'E745:') call assert_fails('echo remove(0z1020, 0, [])', 'E745:') @@ -467,7 +467,7 @@ func Test_blob_read_write() call assert_equal(b, br) call delete('Xblob') END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " This was crashing when calling readfile() with a directory. call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') @@ -485,7 +485,7 @@ func Test_blob_filter() call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails('echo filter(0z10, "a10")', 'E121:') endfunc @@ -496,12 +496,12 @@ func Test_blob_map() call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END call map(0z00, '[9]') END - call CheckLegacyAndVim9Failure(lines, 'E978:') + call v9.CheckLegacyAndVim9Failure(lines, 'E978:') call assert_fails('echo map(0z10, "a10")', 'E121:') endfunc @@ -516,7 +516,7 @@ func Test_blob_index() call assert_equal(0, index(0z11110111, 0x11, -10)) call assert_equal(-1, index(test_null_blob(), 1)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_insert() @@ -529,7 +529,7 @@ func Test_blob_insert() call insert(b, 0x33, 2) call assert_equal(0zDEAD33BEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " only works in legacy script call assert_equal(0, insert(test_null_blob(), 0x33)) @@ -538,42 +538,42 @@ func Test_blob_insert() VAR b = 0zDEADBEEF call insert(b, -1) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 257) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, [9]) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, -20) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, 20) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, []) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) let lines =<< trim END insert(test_null_blob(), 0x33) END - call CheckDefExecAndScriptFailure(lines, 'E1131:') + call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') let lines =<< trim END let b = 0zDEADBEEF @@ -581,7 +581,7 @@ func Test_blob_insert() call insert(b, 3) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') let lines =<< trim END vim9script @@ -589,7 +589,7 @@ func Test_blob_insert() lockvar b insert(b, 3) END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_reverse() @@ -600,7 +600,7 @@ func Test_blob_reverse() call assert_equal(0zDE, reverse(0zDE)) call assert_equal(0z, reverse(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_json_encode() @@ -608,7 +608,7 @@ func Test_blob_json_encode() call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) call assert_equal('[]', json_encode(0z)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_lock() @@ -618,7 +618,7 @@ func Test_blob_lock() unlockvar b let b = 0z44 END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) let lines =<< trim END vim9script @@ -627,14 +627,14 @@ func Test_blob_lock() unlockvar b b = 0z44 END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) let lines =<< trim END let b = 0z112233 lockvar b let b = 0z44 END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') let lines =<< trim END vim9script @@ -642,14 +642,14 @@ func Test_blob_lock() lockvar b b = 0z44 END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_sort() if has('float') - call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') + call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') endif - call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') + call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') endfunc " Tests for the blob2list() function |