Skip to content

Commit 3a0cb38

Browse files
committed
Add test for failing example
1 parent 5db17b8 commit 3a0cb38

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

test/pkgs/PiracyForeignProject/src/PiracyForeignProject.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ module PiracyForeignProject
33
struct ForeignType end
44
struct ForeignParameterizedType{T} end
55

6+
struct ForeignNonSingletonType
7+
x::Int
8+
end
9+
610
end

test/test_piracy.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ push!(LOAD_PATH, joinpath(@__DIR__, "pkgs", "PiracyForeignProject"))
22

33
baremodule PiracyModule
44

5-
using PiracyForeignProject: ForeignType, ForeignParameterizedType
5+
using PiracyForeignProject: ForeignType, ForeignParameterizedType, ForeignNonSingletonType
66

77
using Base:
88
Base,
@@ -44,6 +44,8 @@ export MyUnion
4444
Base.findfirst(::Set{Vector{Char}}, ::Int) = 1
4545
Base.findfirst(::Union{Foo,Bar{Set{Unsigned}},UInt}, ::Tuple{Vararg{String}}) = 1
4646
Base.findfirst(::AbstractChar, ::Set{T}) where {Int <: T <: Integer} = 1
47+
(::ForeignType)(x::Int8) = x + 1
48+
(::ForeignNonSingletonType)(x::Int8) = x + 1
4749

4850
# Piracy, but not for `ForeignType in treat_as_own`
4951
Base.findmax(::ForeignType, x::Int) = x + 1
@@ -75,9 +77,11 @@ end
7577
# 1 from MyUnion
7678
# 6 from findlast
7779
# 3 from findfirst
80+
# 1 from ForeignType
81+
# 1 from ForeignNonSingletonType
7882
# 3 from findmax
7983
# 3 from findmin
80-
@test length(meths) == 2 + 2 + 1 + 6 + 3 + 3 + 3
84+
@test length(meths) == 2 + 2 + 1 + 6 + 3 + 1 + 1 + 3 + 3
8185

8286
# Test what is foreign
8387
BasePkg = Base.PkgId(Base)
@@ -91,22 +95,22 @@ ThisPkg = Base.PkgId(PiracyModule)
9195

9296
# Test what is pirate
9397
pirates = filter(m -> Piracy.is_pirate(m), meths)
94-
@test length(pirates) == 3 + 3 + 3
95-
@test all(pirates) do m
98+
@test length(pirates) == 3 + 3 + 3 + 1 + 1
99+
@test_broken all(pirates) do m
96100
m.name in [:findfirst, :findmax, :findmin]
97101
end
98102

99103
# Test what is pirate (with treat_as_own=[ForeignType])
100104
pirates = filter(m -> Piracy.is_pirate(m; treat_as_own = [ForeignType]), meths)
101-
@test length(pirates) == 3 + 3
102-
@test all(pirates) do m
105+
@test_broken length(pirates) == 3 + 3
106+
@test_broken all(pirates) do m
103107
m.name in [:findfirst, :findmin]
104108
end
105109

106110
# Test what is pirate (with treat_as_own=[ForeignParameterizedType])
107111
pirates = filter(m -> Piracy.is_pirate(m; treat_as_own = [ForeignParameterizedType]), meths)
108-
@test length(pirates) == 3 + 3
109-
@test all(pirates) do m
112+
@test_broken length(pirates) == 3 + 3
113+
@test_broken all(pirates) do m
110114
m.name in [:findfirst, :findmax]
111115
end
112116

@@ -115,16 +119,16 @@ pirates = filter(
115119
m -> Piracy.is_pirate(m; treat_as_own = [ForeignType, ForeignParameterizedType]),
116120
meths,
117121
)
118-
@test length(pirates) == 3
119-
@test all(pirates) do m
122+
@test_broken length(pirates) == 3
123+
@test_broken all(pirates) do m
120124
m.name in [:findfirst]
121125
end
122126

123127
# Test what is pirate (with treat_as_own=[Base.findfirst, Base.findmax])
124128
pirates =
125129
filter(m -> Piracy.is_pirate(m; treat_as_own = [Base.findfirst, Base.findmax]), meths)
126-
@test length(pirates) == 3
127-
@test all(pirates) do m
130+
@test_broken length(pirates) == 3
131+
@test_broken all(pirates) do m
128132
m.name in [:findmin]
129133
end
130134

@@ -136,4 +140,4 @@ pirates = filter(
136140
),
137141
meths,
138142
)
139-
@test length(pirates) == 0
143+
@test_broken length(pirates) == 0

0 commit comments

Comments
 (0)