Skip to content

Commit 02142b2

Browse files
committed
Test u_str error messages
1 parent 4a28973 commit 02142b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/uparse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function map_to_scope(sym::Symbol)
8282
if sym in UNIT_SYMBOLS
8383
return lookup_unit(sym)
8484
elseif sym in CONSTANT_SYMBOLS
85-
throw(ArgumentError("Found the symbol $sym. To access constants in a unit expression, access the `Constants` module. For example, `u\"Constants.h\"`."))
85+
throw(ArgumentError("Symbol $sym found in `Constants` but not `Units`. Please access the `Constants` module. For example, `u\"Constants.$sym\"`."))
8686
return sym
8787
else
8888
throw(ArgumentError("Symbol $sym not found in `Units` or `Constants`."))

test/unittests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ end
471471
@test typeof(u"fm") == DEFAULT_QUANTITY_TYPE
472472
@test typeof(u"fm"^2) == DEFAULT_QUANTITY_TYPE
473473

474-
@test_throws ArgumentError eval(:(u":x"))
474+
@test_throws LoadError eval(:(u"x"))
475+
VERSION >= v"1.9" && @test_throws "Symbol x not found" uparse("x")
476+
VERSION >= v"1.9" && @test_throws "Symbol c found in `Constants` but not `Units`" uparse("c")
475477
end
476478

477479
@testset "Constants" begin

0 commit comments

Comments
 (0)