From 261417b872e6449fe1ca4e7d10f1cfd9736ea453 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 6 May 2021 21:04:55 +0200 Subject: patch 8.2.2840: Vim9: member operation not fully tested Problem: Vim9: member operation not fully tested. Solution: Add a few tests. --- src/testdir/test_vim9_expr.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/testdir/test_vim9_expr.vim') diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index de77b198b..718db8b70 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -3066,6 +3066,10 @@ def Test_expr7_string_subscript() assert_equal('ábçd', text[: 3]) assert_equal('bçdëf', text[1 :]) assert_equal('ábçdëf', text[:]) + + assert_equal('a', g:astring[0]) + assert_equal('sd', g:astring[1 : 2]) + assert_equal('asdf', g:astring[:]) END CheckDefAndScriptSuccess(lines) @@ -3135,6 +3139,9 @@ def Test_expr7_list_subscript() assert_equal([0], list[0 : -5]) assert_equal([], list[0 : -6]) assert_equal([], list[0 : -99]) + + assert_equal(2, g:alist[0]) + assert_equal([2, 3, 4], g:alist[:]) END CheckDefAndScriptSuccess(lines) @@ -3157,6 +3164,9 @@ def Test_expr7_dict_subscript() var res = l[0].lnum > l[1].lnum assert_true(res) + assert_equal(2, g:adict['aaa']) + assert_equal(8, g:adict.bbb) + var dd = {} def Func1() eval dd.key1.key2 @@ -3169,6 +3179,18 @@ def Test_expr7_dict_subscript() CheckDefAndScriptSuccess(lines) enddef +def Test_expr7_blob_subscript() + var lines =<< trim END + var b = 0z112233 + assert_equal(0x11, b[0]) + assert_equal(0z112233, b[:]) + + assert_equal(0x01, g:ablob[0]) + assert_equal(0z01ab, g:ablob[:]) + END + CheckDefAndScriptSuccess(lines) +enddef + def Test_expr7_subscript_linebreak() var lines =<< trim END var range = range( -- cgit v1.2.1