|
| 1 | +# Ensure that Logging.jl works when loaded with `import` rather than `using` |
| 2 | +# since `import` does not bring constants like `DEBUG` into scope: |
| 3 | +module InnerModule |
| 4 | + |
| 5 | +import Logging |
| 6 | +@Logging.configure(level=DEBUG) |
| 7 | + |
| 8 | +using Compat |
| 9 | +using Base.Test |
| 10 | + |
| 11 | +function test_non_global_interpolation(y) |
| 12 | + @info("y = $y") |
| 13 | +end |
| 14 | + |
| 15 | +test_non_global_interpolation(5) |
| 16 | + |
| 17 | +function test_log_macro_common(flags) |
| 18 | + for (macroname, isshown) in flags |
| 19 | + ex = Expr(:macrocall, Symbol(macroname), "test message") |
| 20 | + if isshown |
| 21 | + @test ex |> macroexpand != :nothing |
| 22 | + else |
| 23 | + @test ex |> macroexpand == :nothing |
| 24 | + end |
| 25 | + end |
| 26 | +end |
| 27 | + |
| 28 | +test_log_macro_common([(:@debug, true), (:@info, true), (:@warn, true), |
| 29 | + (:@err, true), (:@critical, true)]) |
| 30 | + |
| 31 | +@Logging.configure(level=INFO) |
| 32 | +test_log_macro_common([(:@debug, false), (:@info, true), (:@warn, true), |
| 33 | + (:@err, true), (:@critical, true)]) |
| 34 | + |
| 35 | +@Logging.configure(level=WARNING) |
| 36 | +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, true), |
| 37 | + (:@err, true), (:@critical, true)]) |
| 38 | + |
| 39 | +@Logging.configure(level=ERROR) |
| 40 | +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), |
| 41 | + (:@err, true), (:@critical, true)]) |
| 42 | + |
| 43 | +@Logging.configure(level=CRITICAL) |
| 44 | +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), |
| 45 | + (:@err, false), (:@critical, true)]) |
| 46 | + |
| 47 | +@Logging.configure(level=OFF) |
| 48 | +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), |
| 49 | + (:@err, false), (:@critical, false)]) |
| 50 | + |
| 51 | +end |
0 commit comments