|
| 1 | +module TestExponentsIterator |
| 2 | + |
| 3 | +using Test |
| 4 | +using MultivariatePolynomials |
| 5 | + |
| 6 | +function _test(object, M; kws...) |
| 7 | + it = ExponentsIterator{M}(object; kws...) |
| 8 | + v = collect(Iterators.take(it, 20)) |
| 9 | + @test issorted(v, lt = (a, b) -> compare(a, b, M)) |
| 10 | +end |
| 11 | + |
| 12 | +function _test(nvars::Int, M; kws...) |
| 13 | + _test(zeros(Int, nvars); inline = false, kws...) |
| 14 | + _test(zeros(Int, nvars); inline = true, kws...) |
| 15 | + _test(ntuple(zero, nvars); inline = false, kws...) |
| 16 | + return |
| 17 | +end |
| 18 | + |
| 19 | +function test_all() |
| 20 | + @testset "nvariables = $nvars" for nvars in 0:3 |
| 21 | + @testset "mindegree = $mindegree" for mindegree in 0:3 |
| 22 | + @testset "maxdegree = $maxdegree" for maxdegree in vcat(nothing; 0:3) |
| 23 | + for L in [LexOrder, InverseLexOrder] |
| 24 | + @testset "M = $M" for M in [ |
| 25 | + L, Graded{L}, |
| 26 | + ] |
| 27 | + _test(nvars, M; mindegree, maxdegree) |
| 28 | + end |
| 29 | + end |
| 30 | + end |
| 31 | + end |
| 32 | + end |
| 33 | +end |
| 34 | + |
| 35 | +function runtests() |
| 36 | + for name in names(@__MODULE__; all = true) |
| 37 | + if startswith("$(name)", "test_") |
| 38 | + @testset "$(name)" begin |
| 39 | + getfield(@__MODULE__, name)() |
| 40 | + end |
| 41 | + end |
| 42 | + end |
| 43 | + return |
| 44 | +end |
| 45 | + |
| 46 | +end # module |
| 47 | + |
| 48 | +TestExponentsIterator.runtests() |
0 commit comments