Skip to content

break breaks push/pop_testset invariance #32937

@tkf

Description

@tkf
julia> using Test

julia> @testset for i in 1:1
           @testset begin
               break
           end
       end
1-element Array{Any,1}:
 Test.DefaultTestSet("i = 1", Any[Test.DefaultTestSet(#= circular reference @-2 =#)], 0, false)

julia> Test.get_testset_depth()  # != 0
1

julia> @testset for i in 1:1  # same testset again
           @testset begin
               break
           end
       end
1-element Array{Any,1}:
 Test.DefaultTestSet("i = 1", Any[Test.DefaultTestSet(#= circular reference @-2 =#)], 0, false)

julia> Test.get_testset_depth()  # != 0
2

I think the code above should be an error. Maybe @testset should be lowered into an "immediately invoked function expression"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviortestsystemThe unit testing framework and Test stdlib

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions