diff src/testdir/test_vim9_expr.vim @ 24602:033b43570140 v8.2.2840

patch 8.2.2840: Vim9: member operation not fully tested Commit: https://github.com/vim/vim/commit/261417b872e6449fe1ca4e7d10f1cfd9736ea453 Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 6 21:04:55 2021 +0200 patch 8.2.2840: Vim9: member operation not fully tested Problem: Vim9: member operation not fully tested. Solution: Add a few tests.
author Bram Moolenaar <Bram@vim.org>
date Thu, 06 May 2021 21:15:04 +0200
parents cb0d344bd381
children 668df21d8bc6
line wrap: on
line diff
--- 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(