Skip to content

Commit 6a07dbc

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

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/loading.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,27 @@ end
131131
test_do_block()
132132
end
133133

134+
@testset "Error upon misuse" begin
135+
@gensym A
136+
@test_throws(
137+
"@__FUNCTION__ can only be used within a function",
138+
@eval(module $A; @__FUNCTION__; end)
139+
)
140+
end
141+
134142
@testset "Callable structs throw error" begin
143+
@gensym A
144+
@eval module $A
135145
struct CallableStruct{T}
136146
val::T
137147
end
138148
function (c::CallableStruct)()
139149
return @__FUNCTION__
140150
end
151+
end
152+
@eval using .$A: CallableStruct
141153
c = CallableStruct(5)
142-
@test_throws UndefVarError c()
143-
end
144-
145-
@testset "Error upon misuse" begin
146-
@gensym A
147-
@test_throws(
148-
"@__FUNCTION__ can only be used within a function",
149-
@eval(module $A; @__FUNCTION__; end)
150-
)
154+
@test_throws "@__FUNCTION__ can only be used within a function" c()
151155
end
152156
end
153157
end

0 commit comments

Comments
 (0)