the `@test` macros create a small amount of context around the given expression, which has the effect of turning the assignment into a (valid) assignment to a new local variable.
On Sat, Apr 18, 2015 at 3:06 PM Gregor R. <[email protected]> wrote: > Is this meant to be or a bug? > > julia> const c = "hello"; > > julia> using Base.Test > > julia> c = 1 > ERROR: invalid redefinition of constant c > > julia> try > c = 1 > catch err > println(err) > end > ErrorException("invalid redefinition of constant c") > > julia> try c = 1; catch err; typeof(err); end > ErrorException > > julia> @test_throws ErrorException c = 1 > ERROR: test failed: c = 1 did not throw ErrorException > in expression: c = 1 > in error at error.jl:19 > in default_handler at test.jl:27 > > The @test_throws macro does not recognize that the following expression > (redefinition of c) throws an ErrorException. >
