Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Nov 13, 2024
1 parent 71793c8 commit 281caa7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion PlotsBase/src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ macro extension_static(be_type, be)
push!(PlotsBase._initialized_backends, $be_sym)
ccall(:jl_generating_output, Cint, ()) == 1 && return
PlotsBase.extension_init($be_type()) # runtime init, incompatible with precompilation
@debug $("Initialized $be_type backend in PlotsBase; run `$be()` to activate it.")
@debug $("Initialized $be_type in PlotsBase; run `$be()` to activate it.")
end
end |> esc
end
Expand Down
13 changes: 7 additions & 6 deletions PlotsBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ get!(ENV, "MPLBACKEND", "agg")

using PlotsBase

# backends weakdeps
import UnitfulLatexify
import LaTeXStrings
import Latexify
import Contour
import Colors

# initialize all backends
for pkg TEST_PACKAGES
@eval begin
Expand Down Expand Up @@ -46,12 +53,6 @@ using FileIO
using Dates
using Test

# backends weakdeps
import UnitfulLatexify
import LaTeXStrings
import Latexify
import Contour

function available_channels()
juliaup = "https://julialang-s3.julialang.org/juliaup"
for i 1:6
Expand Down
35 changes: 17 additions & 18 deletions PlotsBase/test/test_axes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,30 @@
@test PlotsBase.labelfunc_tex(:log2)(1) == "2^{1}"
@test PlotsBase.labelfunc_tex(:ln)(1) == "e^{1}"

# GR is used during tests and it correctly overrides `labelfunc`, but PGFPlotsX did not
with(:pgfplotsx) do
@test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"]
@test PlotsBase.get_labels(:auto, 1:3, :log2) == ["2^{1}", "2^{2}", "2^{3}"]
@test PlotsBase.get_labels(:auto, 1:3, :ln) == ["e^{1}", "e^{2}", "e^{3}"]
@test PlotsBase.get_labels(:latex, 1:3, :log10) ==
["\$10^{1}\$", "\$10^{2}\$", "\$10^{3}\$"]
@test PlotsBase.get_labels(:latex, 1:3, :log2) ==
["\$2^{1}\$", "\$2^{2}\$", "\$2^{3}\$"]
@test PlotsBase.get_labels(:latex, 1:3, :ln) == ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"]
end

@test PlotsBase.get_labels(x -> 1e3x, 1:3, :identity) == ["1000", "2000", "3000"]
@test PlotsBase.get_labels(:auto, 1:3, :identity) == ["1", "2", "3"]
with(:gr) do # NOTE: GR overrides `labelfunc`
@test PlotsBase.get_labels(:auto, 1:3, :identity) == ["1", "2", "3"]
@test PlotsBase.get_labels(:scientific, float.(500:500:1500), :identity) ==
["5.00×10^{2}", "1.00×10^{3}", "1.50×10^{3}"]
@test PlotsBase.get_labels(:engineering, float.(500:500:1500), :identity) ==
["500.×10^{0}", "1.00×10^{3}", "1.50×10^{3}"]
@test PlotsBase.get_labels(:latex, 1:3, :identity) == ["\$1\$", "\$2\$", "\$3\$"]
@test PlotsBase.get_labels(x -> 1e3x, 1:3, :log10) == ["10^{4}", "10^{5}", "10^{6}"]
@test PlotsBase.get_labels(x -> 8x, 1:3, :log2) == ["2^{4}", "2^{5}", "2^{6}"]
@test PlotsBase.get_labels(x ->* x, 1:3, :ln) == ["e^{2}", "e^{3}", "e^{4}"]
end
# GR is used during tests and it correctly overrides `labelfunc`, but PGFPlotsX did not
with(:pgfplotsx) do
@test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"]
end
@test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"]
@test PlotsBase.get_labels(:auto, 1:3, :log2) == ["2^{1}", "2^{2}", "2^{3}"]
@test PlotsBase.get_labels(:auto, 1:3, :ln) == ["e^{1}", "e^{2}", "e^{3}"]
@test PlotsBase.get_labels(:latex, 1:3, :log10) ==
["\$10^{1}\$", "\$10^{2}\$", "\$10^{3}\$"]
@test PlotsBase.get_labels(:latex, 1:3, :log2) ==
["\$2^{1}\$", "\$2^{2}\$", "\$2^{3}\$"]
@test PlotsBase.get_labels(:latex, 1:3, :ln) == ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"]

@test PlotsBase.get_labels(x -> 1e3x, 1:3, :identity) == ["1000", "2000", "3000"]
@test PlotsBase.get_labels(x -> 1e3x, 1:3, :log10) == ["10^{4}", "10^{5}", "10^{6}"]
@test PlotsBase.get_labels(x -> 8x, 1:3, :log2) == ["2^{4}", "2^{5}", "2^{6}"]
@test PlotsBase.get_labels(x ->* x, 1:3, :ln) == ["e^{2}", "e^{3}", "e^{4}"]
@test PlotsBase.get_labels(x -> string(x, " MB"), 1:3, :identity) ==
["1.0 MB", "2.0 MB", "3.0 MB"]
@test PlotsBase.get_labels(x -> string(x, " MB"), 1:3, :log10) ==
Expand Down

0 comments on commit 281caa7

Please sign in to comment.