diff options
| author | James McCoy <jamessan@jamessan.com> | 2018-02-04 07:54:30 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-04 07:54:30 -0500 | 
| commit | 0851057a8deaa1197bd0af22babb62c1146d836c (patch) | |
| tree | a6f796181ed7b76b470d6ce0fbb2df0a836fccae /test/helpers.lua | |
| parent | e2afcfb020fa16b465dd25d3455cd00487e68915 (diff) | |
| parent | de10ea55f370cd57b79d23c2ae09bebf154a0f1a (diff) | |
| download | rneovim-0851057a8deaa1197bd0af22babb62c1146d836c.tar.gz rneovim-0851057a8deaa1197bd0af22babb62c1146d836c.tar.bz2 rneovim-0851057a8deaa1197bd0af22babb62c1146d836c.zip  | |
Merge pull request #7957 from jamessan/lua-functionaltest
[RFC] Ensure build works without LuaJIT available
Diffstat (limited to 'test/helpers.lua')
| -rw-r--r-- | test/helpers.lua | 23 | 
1 files changed, 14 insertions, 9 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index faf5c8e7f2..1c64f41b65 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -423,11 +423,13 @@ format_luav = function(v, indent, opts)      if opts.literal_strings then        ret = v      else -      ret = tostring(v):gsub('[\'\\]', '\\%0'):gsub( -        '[%z\1-\31]', function(match) -          return SUBTBL[match:byte() + 1] -        end) -      ret = '\'' .. ret .. '\'' +      local quote = opts.dquote_strings and '"' or '\'' +      ret = quote .. tostring(v):gsub( +        opts.dquote_strings and '["\\]' or '[\'\\]', +        '\\%0'):gsub( +          '[%z\1-\31]', function(match) +            return SUBTBL[match:byte() + 1] +          end) .. quote      end    elseif type(v) == 'table' then      if v == REMOVE_THIS then @@ -490,11 +492,14 @@ local function format_string(fmt, ...)      if subfmt:sub(-1) ~= '%' then        arg = getarg()      end -    if subfmt:sub(-1) == 'r' then -      -- %r is like %q, but it is supposed to single-quote strings and not -      -- double-quote them, and also work not only for strings. +    if subfmt:sub(-1) == 'r' or subfmt:sub(-1) == 'q' then +      -- %r is like built-in %q, but it is supposed to single-quote strings and +      -- not double-quote them, and also work not only for strings. +      -- Builtin %q is replaced here as it gives invalid and inconsistent with +      -- luajit results for e.g. "\e" on lua: luajit transforms that into `\27`, +      -- lua leaves as-is. +      arg = format_luav(arg, nil, {dquote_strings = (subfmt:sub(-1) == 'q')})        subfmt = subfmt:sub(1, -2) .. 's' -      arg = format_luav(arg)      end      if subfmt == '%e' then        return format_float(arg)  | 
