comparison src/testdir/test_vim9_expr.vim @ 21767:9529a2367d3e v8.2.1433

patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda Commit: https://github.com/vim/vim/commit/ba60cc45e786166767ca80f3dea6236d993c7971 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 12 19:15:33 2020 +0200 patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda Problem: Vim9: cannot mingle comments in multi-line lambda. Solution: Skip over NULL lines. (closes https://github.com/vim/vim/issues/6694)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Aug 2020 19:30:04 +0200
parents 08940efa6b4e
children f37c1330b15c
comparison
equal deleted inserted replaced
21766:283490dee44d 21767:9529a2367d3e
1431 let l = [11 , 22] 1431 let l = [11 , 22]
1432 END 1432 END
1433 CheckScriptFailure(lines, 'E1068:') 1433 CheckScriptFailure(lines, 'E1068:')
1434 enddef 1434 enddef
1435 1435
1436 def LambdaWithComments(): func
1437 return {x ->
1438 # some comment
1439 x == 1
1440 # some comment
1441 ||
1442 x == 2
1443 }
1444 enddef
1445
1436 def Test_expr7_lambda() 1446 def Test_expr7_lambda()
1437 let La = { -> 'result'} 1447 let La = { -> 'result'}
1438 assert_equal('result', La()) 1448 assert_equal('result', La())
1439 assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val})) 1449 assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val}))
1440 1450
1463 assert_equal([{'key': 22}], dl) 1473 assert_equal([{'key': 22}], dl)
1464 1474
1465 dl = [{'key': 12}, {'foo': 34}] 1475 dl = [{'key': 12}, {'foo': 34}]
1466 assert_equal([{'key': 12}], filter(dl, 1476 assert_equal([{'key': 12}], filter(dl,
1467 {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0})) 1477 {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0}))
1478
1479 assert_equal(false, LambdaWithComments()(0))
1480 assert_equal(true, LambdaWithComments()(1))
1481 assert_equal(true, LambdaWithComments()(2))
1482 assert_equal(false, LambdaWithComments()(3))
1468 1483
1469 call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:') 1484 call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
1470 enddef 1485 enddef
1471 1486
1472 def Test_expr7_lambda_vim9script() 1487 def Test_expr7_lambda_vim9script()