From 12c13773488f3f1ca90200eb1aca3ce6a3d2082b Mon Sep 17 00:00:00 2001 From: Randy Boyes Date: Mon, 8 Apr 2024 08:24:19 -0400 Subject: [PATCH] tests for all aes operations added --- test/runtests.jl | 1 + test/test_aes_ops.jl | 154 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 test/test_aes_ops.jl diff --git a/test/runtests.jl b/test/runtests.jl index a85eb72..7ca5b4e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -32,6 +32,7 @@ set_theme!(theme_ggplot2()) # see files for tests include("test_aes.jl") +include("test_aes_ops.jl") include("test_geoms.jl") include("test_labs.jl") include("test_lims.jl") diff --git a/test/test_aes_ops.jl b/test/test_aes_ops.jl new file mode 100644 index 0000000..417dd2a --- /dev/null +++ b/test/test_aes_ops.jl @@ -0,0 +1,154 @@ +@testset verbose = true "aes operations" begin + + @testset "addition" begin + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm + 10, y = :bill_depth_mm + 20)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .+ 10, + penguins.bill_depth_mm .+ 20) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm + :bill_depth_mm, y = :bill_depth_mm)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .+ penguins.bill_depth_mm, + penguins.bill_depth_mm) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + end + + @testset "subtraction" begin + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm - 10, y = :bill_depth_mm - 20)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .- 10, + penguins.bill_depth_mm .- 20) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm - :bill_depth_mm, y = :bill_depth_mm)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .- penguins.bill_depth_mm, + penguins.bill_depth_mm) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + end + + @testset "multiplication" begin + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm * 10, y = :bill_depth_mm * 20)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .* 10, + penguins.bill_depth_mm .* 20) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm * :bill_depth_mm, y = :bill_depth_mm)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm .* penguins.bill_depth_mm, + penguins.bill_depth_mm) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + end + + @testset "division" begin + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm/10, y = :bill_depth_mm/20)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm ./ 10, + penguins.bill_depth_mm ./ 20) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + + t = ggplot(penguins) + + geom_point(aes(x = :bill_length_mm / :bill_depth_mm, y = :bill_depth_mm)) + + m = Makie.plot( + Makie.SpecApi.GridLayout( + Makie.SpecApi.Axis( + plots = [ + Makie.PlotSpec( + :Scatter, + penguins.bill_length_mm ./ penguins.bill_depth_mm, + penguins.bill_depth_mm) + ] + ) + ) + ) + + @test plot_images_equal(t, m) + end +end \ No newline at end of file