require 'Module:BDD'()
local p = require('Module:Timing')

describe({en='statistical analysis', nb='statistisk analyse'}, function()
	context({en='for a constant serie', nb='for en konstant serie'}, function()
		it({en='should give mean', nb='skal finnes middelverdi'}, function()
			expect('"p.stats"', p.stats({ -1, -1, -1 })[1]):toBe( -1 )
			expect('"p.stats"', p.stats({ 0, 0 })[1]):toBe( 0 )
			expect('"p.stats"', p.stats({ 2, 2, 2, 2 })[1]):toBe( 2 )
		end)
		it({en='should give variance', nb='skal finnes varians'}, function()
			expect('"p.stats"', p.stats({ -1, -1, -1 })[2]):toBe( 0 )
			expect('"p.stats"', p.stats({ 0, 0 })[2]):toBe( 0 )
			expect('"p.stats"', p.stats({ 2, 2, 2, 2 })[2]):toBe( 0 )
		end)
	end)
	context({en='for an alternating serie', nb='for en vekslende serie'}, function()
		it({en='should give mean', nb='skal finnes middelverdi'}, function()
			expect('"p.stats"', p.stats({ -1, -1, 1, 1 })[1]):toBe( 0 )
			expect('"p.stats"', p.stats({ 2, 2, 4, 4 })[1]):toBe( 3 )
		end)
		it({en='should give variance', nb='skal finnes varians'}, function()
			expect('"p.stats"', p.stats({ -1, -1, 1, 1 })[2]):toBe( 1 )
			expect('"p.stats"', p.stats({ 2, 2, 4, 4 })[2]):toBe( 1 )
		end)
	end)
end)

describe({en='difference against a baseline', nb='forskjell mot en grunnlinje'}, function()
	context({en='for equal pairs', nb='for like par'}, function()
		it({en='should give mean', nb='skal finnes middelverdi'}, function()
			expect('"p.combine"', p.combine({ -1, 0 }, { -1, 0 })[1]):toBe( 0 )
			expect('"p.combine"', p.combine({ 2, 1 }, { 2, 1 })[1]):toBe( 0 )
		end)
		it({en='should give variance', nb='skal finnes varians'}, function()
			expect('"p.combine"', p.combine({ -1, 0 }, { -1, 0 })[2]):toBe( 0 )
			expect('"p.combine"', p.combine({ 2, 1 }, { 2, 1 })[2]):toBe( math.pow(2, 0.5) )
		end)
	end)
end)

return result('Module:Timing')
"https://si.wikipedia.org/w/index.php?title=Module:Timing/testcases&oldid=722024" වෙතින් සම්ප්‍රවේශනය කෙරිණි