diff options
author | James McCoy <jamessan@jamessan.com> | 2020-07-31 01:33:42 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2020-07-31 01:33:42 -0400 |
commit | 55a885c17930e0f5833e01b35e559886166c9075 (patch) | |
tree | d0bc0015c394732a211c2de4edee3282f94bad99 | |
parent | 817522b2316d10d5139790646da0d0d20039459c (diff) | |
download | rneovim-55a885c17930e0f5833e01b35e559886166c9075.tar.gz rneovim-55a885c17930e0f5833e01b35e559886166c9075.tar.bz2 rneovim-55a885c17930e0f5833e01b35e559886166c9075.zip |
lua: Use #var instead of deprecated table.getn(var)
-rw-r--r-- | test/functional/api/extmark_spec.lua | 54 | ||||
-rw-r--r-- | test/unit/os/env_spec.lua | 2 |
2 files changed, 28 insertions, 28 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 5bf3fa554f..9ea35e50a2 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -204,13 +204,13 @@ describe('API/extmarks', function() eq({marks[2], positions[2][1], positions[2][2]}, rv[2]) -- nextrange with `limit` rv = get_extmarks(ns, marks[1], marks[3], {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) -- nextrange with positional when mark exists at position rv = get_extmarks(ns, positions[1], positions[3]) eq({marks[1], positions[1][1], positions[1][2]}, rv[1]) eq({marks[2], positions[2][1], positions[2][2]}, rv[2]) rv = get_extmarks(ns, positions[2], positions[3]) - eq(2, table.getn(rv)) + eq(2, #rv) -- nextrange with positional index (no mark at position) local lower = {positions[1][1], positions[2][2] -1} local upper = {positions[2][1], positions[3][2] - 1} @@ -248,14 +248,14 @@ describe('API/extmarks', function() eq({marks[1], positions[1][1], positions[1][2]}, rv[3]) -- prevrange with limit rv = get_extmarks(ns, marks[3], marks[1], {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) -- prevrange with positional when mark exists at position rv = get_extmarks(ns, positions[3], positions[1]) eq({{marks[3], positions[3][1], positions[3][2]}, {marks[2], positions[2][1], positions[2][2]}, {marks[1], positions[1][1], positions[1][2]}}, rv) rv = get_extmarks(ns, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) -- prevrange with positional index (no mark at position) lower = {positions[2][1], positions[2][2] + 1} upper = {positions[3][1], positions[3][2] + 1} @@ -282,19 +282,19 @@ describe('API/extmarks', function() end local rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3}) - eq(3, table.getn(rv)) + eq(3, #rv) -- now in reverse rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3}) - eq(3, table.getn(rv)) + eq(3, #rv) end) it('get_marks works when mark col > upper col', function() @@ -798,17 +798,17 @@ describe('API/extmarks', function() feed("u") local rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(3, table.getn(rv)) + eq(3, #rv) feed("<c-r>") rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(3, table.getn(rv)) + eq(3, #rv) -- Test updates feed('o<esc>') set_extmark(ns, marks[1], positions[1][1], positions[1][2]) rv = get_extmarks(ns, marks[1], marks[1], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) feed("u") feed("<c-r>") -- old value is NOT kept in history @@ -820,10 +820,10 @@ describe('API/extmarks', function() feed("u") rv = get_extmarks(ns, {0, 0}, {-1, -1}) -- undo does NOT restore deleted marks - eq(2, table.getn(rv)) + eq(2, #rv) feed("<c-r>") rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) end) it('undo and redo of marks deleted during edits', function() @@ -840,9 +840,9 @@ describe('API/extmarks', function() rv = set_extmark(ns2, marks[1], positions[1][1], positions[1][2]) eq(1, rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, {0, 0}, {-1, -1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- Set more marks for testing the ranges set_extmark(ns, marks[2], positions[2][1], positions[2][2]) @@ -852,32 +852,32 @@ describe('API/extmarks', function() -- get_next (limit set) rv = get_extmarks(ns, {0, 0}, positions[2], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, {0, 0}, positions[2], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- get_prev (limit set) rv = get_extmarks(ns, positions[1], {0, 0}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, positions[1], {0, 0}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- get_next (no limit) rv = get_extmarks(ns, positions[1], positions[2]) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns2, positions[1], positions[2]) - eq(2, table.getn(rv)) + eq(2, #rv) -- get_prev (no limit) rv = get_extmarks(ns, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns2, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) curbufmeths.del_extmark(ns, marks[1]) rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) curbufmeths.del_extmark(ns2, marks[1]) rv = get_extmarks(ns2, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) end) it('mark set can create unique identifiers', function() diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua index e24a389d69..ad05b134e0 100644 --- a/test/unit/os/env_spec.lua +++ b/test/unit/os/env_spec.lua @@ -172,7 +172,7 @@ describe('env.c', function() i = i + 1 name = cimp.os_getenvname_at_index(i) end - eq(true, (table.getn(names)) > 0) + eq(true, #names > 0) eq(true, found_name) end) |