Skip to content

Commit db3e7f1

Browse files
committed
test the real description
1 parent 26d652b commit db3e7f1

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/runtests.jl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,14 @@ end
263263

264264
# issues #43
265265
@testset "macro error" begin
266-
err_type = VERSION < v"1.3" ? LoadError : ArgumentError
267-
@test_throws err_type @macroexpand(IrrationalConstants.@irrational Myπ big(π) Myπ)
268-
@test_throws err_type @macroexpand(IrrationalConstants.@irrational Myπ 1.0 big(π) Myπ)
266+
if VERSION < v"1.3"
267+
@test_throws LoadError @macroexpand(IrrationalConstants.@irrational Myπ big(π) Myπ)
268+
@test_throws LoadError @macroexpand(IrrationalConstants.@irrational Myπ 1.0 big(π) Myπ)
269+
else
270+
msg = "The name of the irrational constant (Myπ) and its type (Myπ) cannot be the same. Please choose a different name for the constant or specify a different type name as the last argument to the macro."
271+
@test_throws ArgumentError(msg) @macroexpand(IrrationalConstants.@irrational Myπ big(π) Myπ)
272+
@test_throws ArgumentError(msg) @macroexpand(IrrationalConstants.@irrational Myπ 1.0 big(π) Myπ)
273+
end
269274
end
270275

271276
# test that defining a type that already exists throws an error
@@ -275,9 +280,16 @@ module TestTypeCollision
275280
struct MyExistingType end
276281

277282
@testset "type collision" begin
278-
err_type = VERSION < v"1.3" ? LoadError : ArgumentError
279-
@test_throws err_type @macroexpand(IrrationalConstants.@irrational myExistingType big(π) MyExistingType)
280-
@test_throws err_type @macroexpand(IrrationalConstants.@irrational myconst big(π) MyExistingType)
281-
@test_throws err_type @macroexpand(IrrationalConstants.@irrational myconst 1.0 big(π) MyExistingType)
283+
if VERSION < v"1.3"
284+
@test_throws LoadError @macroexpand(IrrationalConstants.@irrational myExistingType big(π))
285+
@test_throws LoadError @macroexpand(IrrationalConstants.@irrational myconst big(π) MyExistingType)
286+
@test_throws LoadError @macroexpand(IrrationalConstants.@irrational myconst 1.0 big(π) MyExistingType)
287+
else
288+
msg1 = "Type `MyExistingType` of irrational constant `myExistingType` is already defined in module `Main.TestTypeCollision`."
289+
@test_throws ArgumentError(msg1) @macroexpand(IrrationalConstants.@irrational myExistingType big(π))
290+
msg2 = "Type `MyExistingType` of irrational constant `myconst` is already defined in module `Main.TestTypeCollision`."
291+
@test_throws ArgumentError(msg2) @macroexpand(IrrationalConstants.@irrational myconst big(π) MyExistingType)
292+
@test_throws ArgumentError(msg2) @macroexpand(IrrationalConstants.@irrational myconst 1.0 big(π) MyExistingType)
293+
end
282294
end
283295
end

0 commit comments

Comments
 (0)