From ed0a70087a15621e7f45567feef1900f348c0916 Mon Sep 17 00:00:00 2001 From: Alex Genco Date: Sat, 17 Oct 2020 07:36:36 -0700 Subject: vim-patch:8.1.1056: no eval function for Ruby Problem: No eval function for Ruby. Solution: Add rubyeval(). (Ozaki Kiichi, closes vim/vim#4152) https://github.com/vim/vim/commit/e99be0e6d28fad96efd2b2be23fa38e7559e80e1 --- test/functional/provider/ruby_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/provider/ruby_spec.lua') diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua index bb7d23ede6..2729d8dfa2 100644 --- a/test/functional/provider/ruby_spec.lua +++ b/test/functional/provider/ruby_spec.lua @@ -5,6 +5,7 @@ local command = helpers.command local curbufmeths = helpers.curbufmeths local eq = helpers.eq local eval = helpers.eval +local exc_exec = helpers.exc_exec local expect = helpers.expect local feed = helpers.feed local feed_command = helpers.feed_command @@ -109,3 +110,24 @@ describe('ruby provider', function() eq(2, eval('1+1')) -- Still alive? end) end) + +describe('rubyeval()', function() + it('evaluates ruby objects', function() + eq({1, 2, {['key'] = 'val'}}, funcs.rubyeval('[1, 2, {key: "val"}]')) + end) + + it('returns nil for empty strings', function() + eq(helpers.NIL, funcs.rubyeval('')) + end) + + it('errors out when given non-string', function() + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(10)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(v:_null_dict)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(v:_null_list)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(0.0)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(function("tr"))')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(v:true)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(v:false)')) + eq('Vim(call):E474: Invalid argument', exc_exec('call rubyeval(v:null)')) + end) +end) -- cgit