1
0

Depricated short_builtins.

This commit is contained in:
Jon Michael Aanes 2017-07-24 19:35:19 +02:00
parent 0250c0f014
commit aa4ca9d67d
5 changed files with 13 additions and 21 deletions

View File

@ -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.

View File

@ -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

View File

@ -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.
}

View File

@ -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 }',
}

View File

@ -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.