comparison src/testdir/test_vim9_builtin.vim @ 30787:9f37bcd4d5c5 v9.0.0728

patch 9.0.0728: extend() test fails Commit: https://github.com/vim/vim/commit/a4962cd7bac8464d9f8d95d37614ecf595c5487e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 11 23:12:59 2022 +0100 patch 9.0.0728: extend() test fails Problem: extend() test fails. Solution: Item is final, not const.
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Oct 2022 00:15:03 +0200
parents 56fabd53c7b8
children b4b51e01dd36
comparison
equal deleted inserted replaced
30786:f0329c37cd95 30787:9f37bcd4d5c5
1221 extend(d, {c: 3}) 1221 extend(d, {c: 3})
1222 assert_equal({a: 1, b: 2, c: 3}, d) 1222 assert_equal({a: 1, b: 2, c: 3}, d)
1223 END 1223 END
1224 v9.CheckDefSuccess(lines) 1224 v9.CheckDefSuccess(lines)
1225 1225
1226 # item in a for loop is const 1226 # item in a for loop is final
1227 lines =<< trim END 1227 lines =<< trim END
1228 var l: list<dict<any>> = [{n: 1}] 1228 var l: list<dict<any>> = [{n: 1}]
1229 for item in l 1229 for item in l
1230 item->extend({x: 2}) 1230 item->extend({x: 2})
1231 endfor 1231 endfor
1232 END 1232 END
1233 v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<any>') 1233 v9.CheckDefSuccess(lines)
1234 enddef 1234 enddef
1235 1235
1236 def Test_extendnew() 1236 def Test_extendnew()
1237 assert_equal([1, 2, 'a'], extendnew([1, 2], ['a'])) 1237 assert_equal([1, 2, 'a'], extendnew([1, 2], ['a']))
1238 assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'})) 1238 assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'}))