diff --git a/README.md b/README.md index 614e77f..7777993 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ option a bad value. Tasks to be done before `pretty` can be called version 1.0.0, in order of priority: -- Depricate `max_depth`, `short_builtins` and `recursion` options. +- Depricate `max_depth` and `recursion` options. - Add a dedicated unicode submodule, to handle some minor alignment and character escaping issues. `pretty` should escape all malformed unicode sequences. diff --git a/function.lua b/function.lua index c591b7d..6afd5ed 100644 --- a/function.lua +++ b/function.lua @@ -297,7 +297,7 @@ return function (value, depth, l, format_value) end end - if info.builtin and l.options.short_builtins then + if info.builtin and depth == math.huge then assert(info.name) return l(info.name); end diff --git a/pretty.lua b/pretty.lua index 1e614b3..4e260b2 100644 --- a/pretty.lua +++ b/pretty.lua @@ -549,7 +549,6 @@ local KNOWN_OPTIONS = { indent = { type = 'string', default = ' ' }, max_depth = { type = 'number', default = math.huge }, - short_builtins = { type = 'boolean', default = false }, -- TODO: Outphase this. Rather automatically use the short versions in places where it would be strange to find the function, like keys, etc. recursion = { type = 'string', default = 'ignore', accepted = {['ignore'] = true, ['marked'] = true, ['revisit'] = true} }, -- TODO: Completely depricate this option. I do not like it. } diff --git a/test/test_function.lua b/test/test_function.lua index f844693..d249059 100644 --- a/test/test_function.lua +++ b/test/test_function.lua @@ -228,25 +228,8 @@ format_test { expect = 'builtin function (s [, i [, j]])\n -- string.byte\n -- Returns the internal numerical codes of the characters s[i], s[i+1],\n -- ..., s[j]. The default value for i is 1; the default value for j is\n -- i.\n -- Note that numerical codes are not necessarily portable across\n -- platforms.\n\n ...\nend', } --- short_builtins option: If an builtin is expected to be available by some name --- in a standard enviroment, return that name, instead of other complex info. - format_test { - -- NOTE: These tests may be counter to intention, soon. - input = math.random, - options = { short_builtins = true }, - expect = 'math.random', -} - -format_test { - -- NOTE: These tests may be counter to intention, soon. - input = { math.cos, math.sin, math.abs }, - options = { short_builtins = true }, - expect = '{ math.cos, math.sin, math.abs }', -} - -format_test { - name = 'Replace function with short version, if key', + name = 'If builtin is key, display short name, instead of function signature', input = { [math.random] = 365 }, expect = '{ [math.random] = 365 }', } diff --git a/test/test_pretty.lua b/test/test_pretty.lua index 32c0a5f..cca9c7d 100644 --- a/test/test_pretty.lua +++ b/test/test_pretty.lua @@ -237,6 +237,16 @@ format_test { expect = '{\n djævle = \'dyr?\',\n europa = \'måne\',\n øå = \'en å på en ø?\'\n}', } +format_test { + name = 'Proper alignment when using zero-width unicode characters as keys', + input = { + ['hello_world_1'] = 'dyr?', + ['hello_world_2'] = 'dyr!', + ['hello\204\133_wo\204\133rld_3'] = 'dyr.', + }, + expect = '{\n hello_world_1 = \'dyr?\',\n hello_world_2 = \'dyr!\',\n hello\204\133_wo\204\133rld_3 = \'dyr.\'\n}', +} + -------------------------------------------------------------------------------- -- Pattern specific table display.