Modul:queue/test

Hej, du har kommit hit för att leta efter betydelsen av ordet Modul:queue/test. I DICTIOUS hittar du inte bara alla ordboksbetydelser av ordet Modul:queue/test, utan du får också veta mer om dess etymologi, dess egenskaper och hur man säger Modul:queue/test i singular och plural. Allt du behöver veta om ordet Modul:queue/test finns här. Definitionen av ordet Modul:queue/test hjälper dig att vara mer exakt och korrekt när du talar eller skriver dina texter. Genom att känna till definitionen avModul:queue/test och andra ord berikar du ditt ordförråd och får tillgång till fler och bättre språkliga resurser.

All tests passed. (refresh)

Text Expected Actual
test01_enqueue:
Passed mut.enqueue(q) (nil) (nil)
Text Expected Actual
test02_empty_queue:
Passed mut.isEmpty(q) true true
Passed mut.length(q) 0 0
Passed mut.peekFirst(q) (nil) (nil)
Passed mut.peekSecond(q) (nil) (nil)
Passed mut.peekLast(q) (nil) (nil)
Passed mut.peek(q, 1) (nil) (nil)
Passed mut.peek(q, 0) (nil) (nil)
Passed mut.peek(q, -1) (nil) (nil)
Passed mut.dequeue(q) (nil) (nil)
Text Expected Actual
test03_one_element_added:
Passed mut.isEmpty(q) false false
Passed mut.length(q) 1 1
Passed mut.peekFirst(q) one one
Passed mut.peekSecond(q) (nil) (nil)
Passed mut.peekLast(q) one one
Passed mut.peek(q, 1) one one
Passed mut.peek(q, -1) one one
Passed mut.dequeue(q) one one
Text Expected Actual
test04_two_elements_added:
Passed mut.isEmpty(q) false false
Passed mut.length(q) 2 2
Passed mut.peekFirst(q) one one
Passed mut.peekSecond(q) two two
Passed mut.peekLast(q) two two
Passed mut.peek(q, 1) one one
Passed mut.peek(q, 2) two two
Passed mut.peek(q, -1) two two
Passed mut.peek(q, -2) one one
Text Expected Actual
test05_four_elements_added:
Passed mut.length(q) false false
Passed mut.length(q) 4 4
Passed mut.peekFirst(q) one one
Passed mut.peekSecond(q) two two
Passed mut.peekLast(q) four four
Passed mut.peek(q, 1) one one
Passed mut.peek(q, 4) four four
Passed mut.peek(q, 5) (nil) (nil)
Passed mut.peek(q, 0) (nil) (nil)
Passed mut.peek(q, -1) four four
Passed mut.peek(q, -4) one one
Passed mut.peek(q, -5) (nil) (nil)
Text Expected Actual
test06_multiple:
Passed mut.dequeue(q) (nil) (nil)
Passed mut.length(q) true true
Passed mut.length(q) 0 0
Passed mut.enqueue(q, "one") (nil) (nil)
Passed mut.enqueue(q, "two") (nil) (nil)
Passed mut.length(q) 2 2
Passed mut.dequeue(q) one one
Passed mut.length(q) 1 1
Passed mut.enqueue(q, "three") (nil) (nil)
Passed mut.enqueue(q, "four") (nil) (nil)
Passed mut.length(q) 3 3
Passed mut.dequeue(q) two two
Passed mut.peekFirst(q) three three
Passed mut.peekSecond(q) four four
Passed mut.peekLast(q) four four
Passed mut.length(q) 2 2
Passed mut.dequeue(q) three three
Passed mut.dequeue(q) four four
Passed mut.length(q) true true
Passed mut.dequeue(q) (nil) (nil)
Passed mut.length(q) 0 0
local t = require("Modul:UnitTests")
local mut = require("Modul:queue")

function t:test01_enqueue()
	local q = mut()
	self:equals('mut.enqueue(q)', mut.enqueue(q, "one"), nil)
end

function t:test02_empty_queue()
	-- {}
	local q = mut()
	self:equals('mut.isEmpty(q)', mut.isEmpty(q), true)
	self:equals('mut.length(q)', mut.length(q), 0)
	self:equals('mut.peekFirst(q)', mut.peekFirst(q), nil)
	self:equals('mut.peekSecond(q)', mut.peekSecond(q), nil)
	self:equals('mut.peekLast(q)', mut.peekLast(q), nil)
	self:equals('mut.peek(q, 1)', mut.peek(q, 1), nil)
	self:equals('mut.peek(q, 0)', mut.peek(q, 0), nil)
	self:equals('mut.peek(q, -1)', mut.peek(q, -1), nil)
	self:equals('mut.dequeue(q)', mut.dequeue(q), nil)
end

function t:test03_one_element_added()
	-- {"one"}
	local q = mut()
	mut.enqueue(q, "one")
	self:equals('mut.isEmpty(q)', mut.isEmpty(q), false)
	self:equals('mut.length(q)', mut.length(q), 1)
	self:equals('mut.peekFirst(q)', mut.peekFirst(q), "one")
	self:equals('mut.peekSecond(q)', mut.peekSecond(q), nil)
	self:equals('mut.peekLast(q)', mut.peekLast(q), "one")
	self:equals('mut.peek(q, 1)', mut.peek(q, 1), "one")
	self:equals('mut.peek(q, -1)', mut.peek(q, -1), "one")
	self:equals('mut.dequeue(q)', mut.dequeue(q), "one")
end

function t:test04_two_elements_added()
	-- {"two", "one"}
	local q = mut()
	mut.enqueue(q, "one")
	mut.enqueue(q, "two")
	self:equals('mut.isEmpty(q)', mut.isEmpty(q), false)
	self:equals('mut.length(q)', mut.length(q), 2)
	self:equals('mut.peekFirst(q)', mut.peekFirst(q), "one")
	self:equals('mut.peekSecond(q)', mut.peekSecond(q), "two")
	self:equals('mut.peekLast(q)', mut.peekLast(q), "two")
	self:equals('mut.peek(q, 1)', mut.peek(q, 1), "one")
	self:equals('mut.peek(q, 2)', mut.peek(q, 2), "two")
	self:equals('mut.peek(q, -1)', mut.peek(q, -1), "two")
	self:equals('mut.peek(q, -2)', mut.peek(q, -2), "one")
end

function t:test05_four_elements_added()
	-- {"four", "three", "two", "one"}
	local q = mut()
	mut.enqueue(q, "one")
	mut.enqueue(q, "two")
	mut.enqueue(q, "three")
	mut.enqueue(q, "four")
	self:equals('mut.length(q)', mut.isEmpty(q), false)
	self:equals('mut.length(q)', mut.length(q), 4)
	self:equals('mut.peekFirst(q)', mut.peekFirst(q), "one")
	self:equals('mut.peekSecond(q)', mut.peekSecond(q), "two")
	self:equals('mut.peekLast(q)', mut.peekLast(q), "four")
	self:equals('mut.peek(q, 1)', mut.peek(q, 1), "one")
	self:equals('mut.peek(q, 4)', mut.peek(q, 4), "four")
	self:equals('mut.peek(q, 5)', mut.peek(q, 5), nil)
	self:equals('mut.peek(q, 0)', mut.peek(q, 0), nil)
	self:equals('mut.peek(q, -1)', mut.peek(q, -1), "four")
	self:equals('mut.peek(q, -4)', mut.peek(q, -4), "one")
	self:equals('mut.peek(q, -5)', mut.peek(q, -5), nil)
end

function t:test06_multiple()
	local q = mut()
	-- {}
	self:equals('mut.dequeue(q)', mut.dequeue(q), nil)
	self:equals('mut.length(q)', mut.isEmpty(q), true)
	self:equals('mut.length(q)', mut.length(q), 0)
	-- {}
	self:equals('mut.enqueue(q, "one")', mut.enqueue(q, "one"), nil)
	self:equals('mut.enqueue(q, "two")', mut.enqueue(q, "two"), nil)
	-- {"two", "one"}
	self:equals('mut.length(q)', mut.length(q), 2)
	self:equals('mut.dequeue(q)', mut.dequeue(q), "one")
	-- {"two"}
	self:equals('mut.length(q)', mut.length(q), 1)
	self:equals('mut.enqueue(q, "three")', mut.enqueue(q, "three"), nil)
	self:equals('mut.enqueue(q, "four")', mut.enqueue(q, "four"), nil)
	-- {"four", "three", "two"}
	self:equals('mut.length(q)', mut.length(q), 3)
	self:equals('mut.dequeue(q)', mut.dequeue(q), "two")
	-- {"four", "three"}
	self:equals('mut.peekFirst(q)', mut.peekFirst(q), "three")
	self:equals('mut.peekSecond(q)', mut.peekSecond(q), "four")
	self:equals('mut.peekLast(q)', mut.peekLast(q), "four")
	self:equals('mut.length(q)', mut.length(q), 2)
	self:equals('mut.dequeue(q)', mut.dequeue(q), "three")
	self:equals('mut.dequeue(q)', mut.dequeue(q), "four")
	-- {}
	self:equals('mut.length(q)', mut.isEmpty(q), true)
	self:equals('mut.dequeue(q)', mut.dequeue(q), nil)
	-- {}
	self:equals('mut.length(q)', mut.length(q), 0)
end

return t