1
0

Removed unused functionallity, and associated tests.

This commit is contained in:
Jon Michael Aanes 2017-04-14 13:09:05 +02:00
parent 87b12e15b2
commit 9050d53962
2 changed files with 0 additions and 87 deletions

View File

@ -119,20 +119,6 @@ local function contains_only_nice_string_keys (t)
return true
end
local function contains_only_nice_number_indexes (t)
-- Predicate: Does t contain only number keys, all of which are integer,
-- larger than/equal 1 and less than the maximum index.
local max_index = largest_number_index(t)
for k, v in pairs(t) do
if type(k) ~= 'number' or k < 1 or max_index < k or k ~= math.floor(k) then
return false
end
end
return #t > 0
end
local function is_set (t)
-- Predicate: Does t contain only boolean values.
local value_types = get_value_types(t)
@ -167,36 +153,6 @@ local function is_tabular (t)
return true
end
local is_short_table, is_simple_value
function is_short_table (value)
-- Predicate: value is either an empty table, or one with a single simple
-- non-function element.
if type(value) ~= 'table' then
error(('[pretty/internal]: Only tables allowed in function analyze_structure.is_short_table, but was given %s (%s)'):format(value, type(value)), 2)
end
local first_key = next(value, nil)
if not first_key then
return true
elseif not next(value, first_key) == nil then
return false
end
return type(value[first_key]) ~= 'table'
and is_simple_value( value[first_key] )
end
function is_simple_value (value)
-- Predicate: value is either nil, a boolean, a number, a short string or a
-- short table.
return SIMPLE_VALUE_TYPES[ type(value) ]
or type(value) == 'string' and #value <= SHORT_STRING_MAX_LEN
or type(value) == 'table' and is_short_table(value)
end
--------------------------------------------------------------------------------
local function get_table_info (t)
@ -210,7 +166,6 @@ local function get_table_info (t)
info.has_map = info.map_elems > 0
info.is_set = is_set(t) and info.nr_elems >= MINIMUM_NUMBER_OF_SET_ELEMENTS
info.is_tabular = is_tabular(t)
info.is_short = is_short_table(t) -- TODO: Remove this. It's not used for anything.
-- Determine type of table
if not info.has_seq and not info.has_map then info.type = TABLE_TYPE.EMPTY

View File

@ -125,48 +125,6 @@ SUITE:addTest('Not Tabular, due to varying lengths', function ()
assert(table_info.is_tabular == false)
end)
SUITE:addTest('Very short/empty table', function ()
local input = { }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == true)
end)
SUITE:addTest('Very short table', function ()
local input = { 1 }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == true)
end)
SUITE:addTest('Recursive tables are not simple', function ()
local input = { {} }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == false)
end)
SUITE:addTest('Short strings are simple', function ()
local input = { 'hello' }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == true)
end)
SUITE:addTest('Long strings are not', function ()
local input = { 'hello world' }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == false)
end)
SUITE:addTest('Even maps can be simple!', function ()
local input = { a = 4 }
local table_info = analyze_structure(input)[input]
assert(table_info.is_short == true)
end)
--------------------------------------------------------------------------------
-- Corner cases.