Module:math/testcases

Hello, you have come here looking for the meaning of the word Module:math/testcases. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:math/testcases, but we will also tell you about its etymology, its characteristics and you will know how to say Module:math/testcases in singular and plural. Everything you need to know about the word Module:math/testcases you have here. The definition of the word Module:math/testcases will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:math/testcases, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

All tests passed. (refresh)

TextExpectedActual
test_gcd:
Passed
(1)
11
Passed
(-1)
11
Passed
(0)
00
Passed
(0, 0)
00
Passed
(1, 0)
11
Passed
(0, 1)
11
Passed
(1, 1)
11
Passed
(6, 4)
22
Passed
(6, -4)
22
Passed
(-6, -4)
22
Passed
(2, 8)
22
Passed
(15, 20)
55
Passed
(20, 15)
55
Passed
(35, -21)
77
Passed
(48, 18)
66
Passed
(8, 12, 16)
44
Passed
(25, -35, 95)
55
Passed
(95, -35, 25)
55
Passed
(1500, 750, 150000, 625)
125125
Passed
(186028, 193052, 144624)
44
Passed2^100, 2^539.007199254741e+159.007199254741e+15
TextExpectedActual
test_lcm:
Passed
(1)
11
Passed
(-1)
11
Passed
(0)
00
Passed
(0, 0)
00
Passed
(1, 0)
00
Passed
(0, 1)
00
Passed
(1, 1)
11
Passed
(6, 4)
1212
Passed
(6, -4)
1212
Passed
(-6, -4)
1212
Passed
(2, 8)
88
Passed
(15, 20)
6060
Passed
(20, 15)
6060
Passed
(35, -21)
105105
Passed
(48, 18)
144144
Passed
(8, 12, 16)
4848
Passed
(25, -35, 95)
33253325
Passed
(95, -35, 25)
33253325
Passed
(1500, 750, 150000, 625)
150000150000
Passed
(186028, 193052, 144624)
3.2461830712478e+143.2461830712478e+14
Passed2^100, 2^531.2676506002282e+301.2676506002282e+30
TextExpectedActual
test_sign:
Passed
(1)
11
Passed
(5)
11
Passed
(1.3)
11
Passed
(0.8)
11
Passed
(100)
11
Passed
(1e+308)
11
Passed
(inf)
11
Passed
(nan)
11
Passed
("1")
11
Passed
("2.5")
11
Passed
("inf")
11
Passed
("nan")
11
Passed
(0)
00
Passed
("0")
00
Passed
(0, true)
11
Passed
("0", true)
11
Passed
(-1)
-1-1
Passed
(-5)
-1-1
Passed
(-1.3)
-1-1
Passed
(-0.8)
-1-1
Passed
(-100)
-1-1
Passed
(-1e+308)
-1-1
Passed
(-inf)
-1-1
Passed
(-nan)
-1-1
Passed
("-1")
-1-1
Passed
("-2.5")
-1-1
Passed
("-inf")
-1-1
Passed
("-nan")
-1-1
Passed
(-0)
00
Passed
("-0")
00
Passed
(-0, true)
-1-1
Passed
("-0", true)
-1-1

local tests = require("Module:UnitTests")
local m_math = require("Module:math")

local concat = table.concat
local dump = mw.dumpObject
local gcd = m_math.gcd
local highlight = require("Module:debug").highlight
local lcm = m_math.lcm
local sign = m_math.sign
local tonumber = tonumber
local unpack = unpack or table.unpack -- Lua 5.2 compatibility

local INF = math.huge
local NEG_INF = -INF
local NAN = tonumber("nan")
local NEG_NAN = tonumber("-nan")

local function do_test(func, args, expected, name)
	if name == nil then
		name = {}
		for i, v in ipairs(args) do
			name = dump(v)
		end
		name = highlight("(" .. concat(name, ", ") .. ")")
	end
	tests:equals(name, func(unpack(args)), expected)
end

function tests:check_sign(args, expected, name)
	return do_test(sign, args, expected, name)
end

function tests:test_sign()
	self:iterate({
		{{1}, 1},
		{{5}, 1},
		{{1.3}, 1},
		{{0.8}, 1},
		{{100}, 1},
		{{1e308}, 1},
		{{INF}, 1},
		{{NAN}, 1},
		{{"1"}, 1},
		{{"2.5"}, 1},
		{{"inf"}, 1},
		{{"nan"}, 1},
		{{0}, 0},
		{{"0"}, 0},
		{{0, true}, 1},
		{{"0", true}, 1},
		{{-1}, -1},
		{{-5}, -1},
		{{-1.3}, -1},
		{{-0.8}, -1},
		{{-100}, -1},
		{{-1e308}, -1},
		{{NEG_INF}, -1},
		{{NEG_NAN}, -1},
		{{"-1"}, -1},
		{{"-2.5"}, -1},
		{{"-inf"}, -1},
		{{"-nan"}, -1},
		{{tonumber("-0")}, 0},
		{{"-0"}, 0},
		{{tonumber("-0"), true}, -1},
		{{"-0", true}, -1},
		
	}, "check_sign")
end

function tests:check_gcd(args, expected, name)
	return do_test(gcd, args, expected, name)
end

function tests:test_gcd()
	self:iterate({
		{{1}, 1},
		{{-1}, 1},
		{{0}, 0},
		{{0, 0}, 0},
		{{1, 0}, 1},
		{{0, 1}, 1},
		{{1, 1}, 1},
		{{6, 4}, 2},
		{{6, -4}, 2},
		{{-6, -4}, 2},
		{{2, 8}, 2},
		{{15, 20}, 5},
		{{20, 15}, 5},
		{{35, -21}, 7},
		{{48, 18}, 6},
		{{8, 12, 16}, 4},
		{{25, -35, 95}, 5},
		{{95, -35, 25}, 5},
		{{1500, 750, 150000, 625}, 125},
		{{186028, 193052, 144624}, 4},
		{{2^100, 2^53}, 2^53, "2^100, 2^53"},
	}, "check_gcd")
end

function tests:check_lcm(args, expected, name)
	return do_test(lcm, args, expected, name)
end

function tests:test_lcm()
	self:iterate({
		{{1}, 1},
		{{-1}, 1},
		{{0}, 0},
		{{0, 0}, 0},
		{{1, 0}, 0},
		{{0, 1}, 0},
		{{1, 1}, 1},
		{{6, 4}, 12},
		{{6, -4}, 12},
		{{-6, -4}, 12},
		{{2, 8}, 8},
		{{15, 20}, 60},
		{{20, 15}, 60},
		{{35, -21}, 105},
		{{48, 18}, 144},
		{{8, 12, 16}, 48},
		{{25, -35, 95}, 3325},
		{{95, -35, 25}, 3325},
		{{1500, 750, 150000, 625}, 150000},
		{{186028, 193052, 144624}, 324618307124784},
		{{2^100, 2^53}, 2^100, "2^100, 2^53"},
	}, "check_lcm")
end

return tests