view src/testdir/test85.in @ 3736:dc65e6429d2c v7.3.627

updated for version 7.3.627 Problem: When using the "n" flag with the ":s" command a \= substitution will not be evaluated. Solution: Do perform the evaluation, so that a function can be invoked at every matching position without changing the text. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 08 Aug 2012 16:51:15 +0200
parents e070b34fe35e
children af3a3680fc75
line wrap: on
line source

Test for Lua interface and luaeval() function

STARTTEST
:so small.vim
:so lua.vim
:set nocompatible viminfo+=nviminfo
:lua l = vim.list():add"item0":add"dictionary with list OK":add"item2"
:lua h = vim.dict(); h.list = l
:call garbagecollect()
/^1
:" change buffer contents
:lua curbuf = vim.buffer()
:lua curline = vim.eval"line('.')"
:lua curbuf[curline] = "1 changed line 1"
:" scalar test
:let tmp_string = luaeval('"string"')
:let tmp_1000 = luaeval('1000')
:if printf("%s%.0f", tmp_string, tmp_1000) == "string1000"
:let scalar_res = "OK"
:else
:let scalar_res = "FAILED"
:endif
:call append(search("^1"), "scalar test " . scalar_res)
:" dictionary containing a list
:let tmp = luaeval("h").list[1]
:/^2/put =tmp
:" circular list (at the same time test lists containing lists)
:lua l[2] = l
:let l2 = luaeval("h").list
:if l2[2] == l2
:let res = "OK"
:else
:let res = "FAILED"
:endif
:call setline(search("^3"), "circular test " . res)
:?^1?,$w! test.out
:qa!
ENDTEST

1 line 1
2 line 2
3 line 3