Skip to content

Commit fd8a3d2

Browse files
committed
make sure testset in function will still trigger error
1 parent 8b562af commit fd8a3d2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/loading.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,24 @@ end
131131
test_do_block()
132132
end
133133

134-
@testset "Callable structs throw error" begin
135-
struct CallableStruct{T}
136-
val::T
137-
end
138-
function (c::CallableStruct)()
139-
return @__FUNCTION__
140-
end
141-
c = CallableStruct(5)
142-
@test_throws UndefVarError c()
143-
end
144-
145134
@testset "Error upon misuse" begin
146135
@gensym A
147136
@test_throws(
148137
"@__FUNCTION__ can only be used within a function",
149138
@eval(module $A; @__FUNCTION__; end)
150139
)
151140
end
141+
142+
@testset "Callable structs throw error" begin
143+
@gensym A
144+
@eval module $A
145+
struct CallableStruct{T}; val::T; end
146+
(c::CallableStruct)() = @__FUNCTION__
147+
end
148+
@eval using .$A: CallableStruct
149+
c = CallableStruct(5)
150+
@test_throws "@__FUNCTION__ can only be used within a function" c()
151+
end
152152
end
153153
end
154154

0 commit comments

Comments
 (0)