|
1 | 1 | module TestPatterns
|
2 | 2 | using Test
|
3 | 3 |
|
4 |
| -using ReTest: and, or, not, interpolated, reachable, depth |
| 4 | +using ReTest: and, or, not, interpolated, reachable, depth, pass, fail |
| 5 | +import ReTest |
| 6 | + |
| 7 | +struct MockTestset |
| 8 | + id |
| 9 | + pastresults |
| 10 | + parent |
| 11 | + |
| 12 | + MockTestset() = new(rand(1:typemax(Int)), Dict(), nothing) |
| 13 | +end |
| 14 | + |
| 15 | +ReTest.tsdepth(::MockTestset) = 1 |
| 16 | + |
| 17 | +const basic_patterns = [and(), or(), not(0), interpolated, 0, r"", depth(2), pass, fail] |
| 18 | +VERSION >= v"1.3" && push!(basic_patterns, reachable(1)) |
5 | 19 |
|
6 | 20 | @testset "patterns: ==" begin
|
7 |
| - basics = [and(), or(), not(0), interpolated, 0, r"", depth(2)] |
8 |
| - VERSION >= v"1.3" && push!(basics, reachable(1)) |
9 |
| - for a = basics, b = basics |
| 21 | + for a = basic_patterns, b = basic_patterns |
10 | 22 | if a === b
|
11 | 23 | @test a == b
|
12 | 24 | if !(a isa Regex || a isa Integer)
|
@@ -42,6 +54,15 @@ using ReTest: and, or, not, interpolated, reachable, depth
|
42 | 54 | end
|
43 | 55 | end
|
44 | 56 |
|
| 57 | +@testset "patterns: interface" begin |
| 58 | + for a in basic_patterns |
| 59 | + @test ReTest.matches(a, "a", MockTestset()) isa Union{Missing, Bool} |
| 60 | + @test ReTest.matches(a, missing, MockTestset()) isa Union{Missing, Bool} |
| 61 | + @test ReTest.alwaysmatches(a, 1) isa Bool |
| 62 | + @test ReTest.hasinteger(a) isa Bool |
| 63 | + end |
| 64 | +end |
| 65 | + |
45 | 66 | @testset "patterns: not" begin
|
46 | 67 | pats = [or(1, 3), and(1, r"a"), not(1), interpolated, depth(3)]
|
47 | 68 | VERSION >= v"1.3" && push!(pats, reachable("c"))
|
|
0 commit comments