🌟現在、鉄壁 鉄壁ヘッドショットには対応済みです。
鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。

モジュール:TableExtensions/testcases

提供:Apex Data
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:TableExtensions/testcases/doc に作成できます

local p = {}

local table      = require('Module:TableExtensions')
local TestHelper = require('Module:Utility/TestHelper')

-- データ定義
local empty = {}
local indexonly = { 1, 4, 9 }
local keyonly = {
	["min-width"] = "20px",
	["max-width"] = "80px",
}
local mixed = {
	1, 4, 9,
	["min-width"] = "20px",
	["max-width"] = "80px",
}

-- [table.isEmpty] case: Invalid
local function isEmptyInvalid()
	return table.isEmpty(false)
end

-- [table.isEmpty] case: True
local function isEmptyTrue()
	return table.isEmpty(empty)
end

-- [table.isEmpty] case: False
local function isEmptyFalse()
	return table.isEmpty(mixed)
end

-- [table.keys] case: Invalid
local function keysInvalid()
	return table.keys(false)
end

-- [table.keys] case: 1, 2, 3
local function keysIndexOnly()
	return table.keys(indexonly)
end

-- [table.keys] case: "min-width", "max-width"
local function keysKeyOnly()
	return table.keys(keyonly)
end

-- [table.keys] case: 1, 2, 3, "min-width", "max-width"
local function keysMixed()
	return table.keys(mixed)
end

-- [table.values] case: Invalid
local function valuesInvalid()
	return table.values(false)
end

-- [table.values] case: 1, 4, 9
local function valuesIndexOnly()
	return table.values(indexonly)
end

-- [table.values] case: "20px", "80px"
local function valuesKeyOnly()
	return table.values(keyonly)
end

-- [table.values] case: 1, 4, 9, "20px", "80px"
local function valuesMixed()
	return table.values(mixed)
end

-- [table.entries] case: Invalid
local function entriesInvalid()
	return table.entries(false)
end

-- [table.entries] case: (1, 1), (2, 4), (3, 9)
local function entriesIndexOnly()
	return table.entries(indexonly)
end

-- [table.entries] case: ("min-width", "20px"), ("max-width", "80px")
local function entriesKeyOnly()
	return table.entries(keyonly)
end

-- [table.entries] case: (1, 1), (2, 4), (3, 9), ("min-width", "20px"), ("max-width", "80px")
local function entriesMixed()
	return table.entries(mixed)
end

-- [table.map] case: square
local function mapSquare()
	return table.map(indexonly, function(k, v) return v * v end)
end

-- [table.mapKeys] case: uppercase
local function mapKeysUppercase()
	return table.mapKeys(keyonly, function(k) return string.upper(k) end)
end

-- [table.mapValues] case: square
local function mapValuesSquare()
	return table.mapValues(indexonly, function(v) return v * v end)
end

-- [table.filter] case: value > 1
local function filterGreaterThan1()
	return table.filter(indexonly, function(_, v) return v > 1 end)
end

-- [table.filter] case: value <= 4
local function filterLessThanOrEqualTo4()
	return table.filter(indexonly, function(_, v) return v <= 4 end)
end

-- [table.filter] case: key contains "max"
local function filterStringFindMax()
	return table.filter(keyonly, function(k, _) return string.find(k, "max") end)
end

-- [table.removeKey] case: Invalid
local function removeKeyInvalid()
	return table.removeKey(false, "min-width")
end

-- [table.removeKey] case: Remove
local function removeKey()
	local tbl = {
		["min-width"] = "20px",
		["max-width"] = "80px",
	}
	table.removeKey(tbl, "min-width")
	return tbl
end

-- テスト結果
function p.result()
	local testcases = {
		['[table.isEmpty] case: Invalid'] = { func = isEmptyInvalid, hasError = true },
		['[table.isEmpty] case: True']    = { func = isEmptyTrue,    expected = true },
		['[table.isEmpty] case: False']   = { func = isEmptyFalse,   expected = false },
		
		['[table.keys] case: Invalid']                            = { func = keysInvalid,   hasError = true },
		['[table.keys] case: 1, 2, 3']                            = { func = keysIndexOnly, expected = { 1, 2, 3 } },
		['[table.keys] case: "min-width", "max-width"']           = { func = keysKeyOnly,   expected = { "min-width", "max-width" } },
		['[table.keys] case: 1, 2, 3, "min-width", "max-width"']  = { func = keysMixed,     expected = { 1, 2, 3, "min-width", "max-width" } },
		
		['[table.values] case: Invalid']                  = { func = valuesInvalid,   hasError = true },
		['[table.values] case: 1, 4, 9']                  = { func = valuesIndexOnly, expected = { 1, 4, 9 } },
		['[table.values] case: "20px", "80px"']           = { func = valuesKeyOnly,   expected = { "20px", "80px" } },
		['[table.values] case: 1, 4, 9, "20px", "80px"']  = { func = valuesMixed,     expected = { 1, 4, 9, "20px", "80px" } },
		
		['[table.entries] case: Invalid']                                                               = { func = entriesInvalid,  hasError = true },
		['[table.entries] case: (1, 1), (2, 4), (3, 9)']                                                = { func = entriesIndexOnly, expected = { { 1, 1}, { 2, 4 }, { 3, 9 } } },
		['[table.entries] case: ("min-width", "20px"), ("max-width", "80px")']                          = { func = entriesKeyOnly,   expected = { { "min-width", "20px" }, { "max-width", "80px" } } },
		['[table.entries] case: (1, 1), (2, 4), (3, 9), ("min-width", "20px"), ("max-width", "80px")']  = { func = entriesMixed,     expected = { { 1, 1}, { 2, 4 }, { 3, 9 }, { "min-width", "20px" }, { "max-width", "80px" } } },
		
		['[table.map] case: square']        = { func = mapSquare, expected = { 1, 16, 81 } },
		['[table.mapKeys] case: uppercase'] = { func = mapKeysUppercase, expected = { ["MIN-WIDTH"] = "20px", ["MAX-WIDTH"] = "80px" } },
		['[table.mapValues] case: square']  = { func = mapValuesSquare, expected = { 1, 16, 81 } },
		
		['[table.filter] case: value > 1']           = { func = filterGreaterThan1,       expected = { 4, 9 } },
		['[table.filter] case: value <= 4']          = { func = filterLessThanOrEqualTo4, expected = { 1, 4 } },
		['[table.filter] case: key contains "max"']  = { func = filterStringFindMax,      expected = { ["max-width"] = "80px" } },
		
		['[table.removeKey] case: Invalid'] = { func = removeKeyInvalid, hasError = true },
		['[table.removeKey] case: Remove']  = { func = removeKey, expected = { ["max-width"] = "80px" } },
	}
	return TestHelper.executeAsNode(testcases)
end

-- エントリーポイント
function p.main()
	return tostring(p.result())
end

return p