From 227a261795f909d553868240287b096cfb70f503 Mon Sep 17 00:00:00 2001 From: Peter Deffebach Date: Wed, 7 Jul 2021 10:22:42 -0400 Subject: [PATCH] tests pass --- test/dataframes.jl | 4 ++-- test/deprecated.jl | 42 ++++++++++++++++++++++++++++++++++++ test/function_compilation.jl | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/test/dataframes.jl b/test/dataframes.jl index 16104a8f..64360d5e 100644 --- a/test/dataframes.jl +++ b/test/dataframes.jl @@ -280,7 +280,7 @@ s = [:i, :g] @test_throws LoadError @eval @transform(df, Not([:i, :g])) @test_throws MethodError @eval @transform(df, :n = sum(Between(:i, :t))) @test_throws ArgumentError @eval @transform(df, :n = sum(cols(s))) - @test_throws ArgumentError @eval @transform(df, y = :i + cols(1)) + @test_throws ArgumentError @eval @transform(df, :y = :i + cols(1)) end @testset "@select" begin @@ -554,7 +554,7 @@ cr = "c" @test_throws LoadError @eval @select(df, Not([:i, :g])) @test_throws MethodError @eval @select(df, :n = sum(Between(:i, :t))) @test_throws ArgumentError @eval @select(df, :n = sum(cols(s))) - @test_throws ArgumentError @eval @select(df, y = :i + cols(1)) + @test_throws ArgumentError @eval @select(df, :y = :i + cols(1)) end @testset "Keyword arguments failure" begin diff --git a/test/deprecated.jl b/test/deprecated.jl index 0412d57a..b76c8cbc 100644 --- a/test/deprecated.jl +++ b/test/deprecated.jl @@ -159,4 +159,46 @@ end @test @where(gd, :c .== :g) ≅ df[[], :] end +@testset "Unquoted symbols on LHS" begin + df = DataFrame( + g = [1, 1, 1, 2, 2], + i = 1:5, + t = ["a", "b", "c", "c", "e"], + y = [:v, :w, :x, :y, :z], + c = [:g, :quote, :body, :transform, missing] + ) + + gd = groupby(df, :g) + + newdf = @transform df :n = :i + + @test (@transform df n = :i) ≅ newdf + @test (@transform(df, n = identity(:i))) ≅ newdf + @test (@transform df @byrow n = :i) ≅ newdf + d = @transform df begin + n = identity(:i) + end + @test d ≅ newdf + + d = @eachrow df begin + @newcol n::Vector{Int} + :n = :i + end + @test d ≅ newdf + + newdf = @select df :n = :i + + @test (@select df n = :i) ≅ newdf + @test (@select(df, n = identity(:i))) ≅ newdf + d = @select df begin + n = identity(:i) + end + @test (@select df @byrow n = :i) ≅ newdf + @test d ≅ newdf + + newdf = @combine gd :n = first(:i) + @test (@combine gd n = first(:i)) ≅ newdf + @test (@combine(gd, n = first(:i))) ≅ newdf +end + end # module \ No newline at end of file diff --git a/test/function_compilation.jl b/test/function_compilation.jl index 34ebb66a..4c411f61 100644 --- a/test/function_compilation.jl +++ b/test/function_compilation.jl @@ -154,7 +154,7 @@ using DataFramesMeta gd = groupby(df, :a) - @test @combine(gd, testnt(:b)) == DataFrame(a = [1], :c = [2]) + @test @combine(gd, testnt(:b)) == DataFrame(a = [1], c = [2]) fasttime = @timed @combine(gd, testnt(:b)) slowtime = @timed combine(gd, :b => (b -> testnt(b)) => AsTable)