-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotiteratorfactory_test.lua
More file actions
43 lines (33 loc) · 1.38 KB
/
Copy pathplotiteratorfactory_test.lua
File metadata and controls
43 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local luaunit = require("luaunit")
local checks = require("luatypechecks.checks")
local Range = require("luamath.models.range")
local Plot = require("luaplot.plot")
local PlotIterator = require("luaplot.plotiterator")
local PlotIteratorFactory = require("luaplot.plotiteratorfactory")
-- luacheck: globals TestPlotIteratorFactory
TestPlotIteratorFactory = {}
function TestPlotIteratorFactory.test_new()
local function transformer()
assert(false, "it should not be called")
end
local factory = PlotIteratorFactory:new(transformer)
luaunit.assert_is_table(factory)
luaunit.assert_true(checks.is_instance(factory, PlotIteratorFactory))
luaunit.assert_is_function(factory._transformer)
luaunit.assert_equals(factory._transformer, transformer)
end
function TestPlotIteratorFactory.test_with()
local function transformer()
assert(false, "it should not be called")
end
local plot = Plot:new(5, 32, Range:new(23, 42))
local factory = PlotIteratorFactory:new(transformer)
local iterator = factory:with(plot)
luaunit.assert_is_table(iterator)
luaunit.assert_true(checks.is_instance(iterator, PlotIterator))
luaunit.assert_is_table(iterator._plot)
luaunit.assert_true(checks.is_instance(iterator._plot, Plot))
luaunit.assert_equals(iterator._plot, plot)
luaunit.assert_is_function(iterator._transformer)
luaunit.assert_equals(iterator._transformer, transformer)
end