Skip to content

Commit

Permalink
more r_base::== tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Feb 6, 2024
1 parent 1fce08d commit bd61eb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 140 deletions.
16 changes: 6 additions & 10 deletions duckdb-rfuns-r/tests/testthat/gen/eq.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ FALSE == 'fAlse'
'1' == 1.0
'1' == NA_real_
NA_character_ == 3.0

"<dbl> == <str>"
1.0 == '2'
1.0 == '1'
NA_real_ == "2"
Expand All @@ -110,15 +112,9 @@ NA_real_ == "2"
"<int> == <str>"
NA_integer_ == "string"
1L == "1"
1L == NA_character_

"<str> == <int>"
"string" == NA_integer_
"1" == 1L

"<int> == <dbl>"
2L == 1.0
1L == 1.0
NA_integer_ == 1.0
3L == NA_real_
1.0 == 2L
1.0 == 1L
1.0 == NA_integer_
NA_real_ == 3L
NA_character_ == 2L
146 changes: 16 additions & 130 deletions duckdb-rfuns-r/tests/testthat/test-generated-eq.R
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ test_that('<str> == <dbl> :: NA_character_ == 3', {
expect_identical(out_df[, 1], NA_character_ == 3)
})

test_that('<str> == <dbl> :: 1 == "2"', {
test_that('<dbl> == <str> :: 1 == "2"', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1, x2 = "2")
in_rel <- duckdb:::rel_from_df(con, in_df)
Expand All @@ -1595,7 +1595,7 @@ test_that('<str> == <dbl> :: 1 == "2"', {
expect_identical(out_df[, 1], 1 == "2")
})

test_that('<str> == <dbl> :: 1 == "1"', {
test_that('<dbl> == <str> :: 1 == "1"', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1, x2 = "1")
in_rel <- duckdb:::rel_from_df(con, in_df)
Expand All @@ -1614,7 +1614,7 @@ test_that('<str> == <dbl> :: 1 == "1"', {
expect_identical(out_df[, 1], 1 == "1")
})

test_that('<str> == <dbl> :: NA_real_ == "2"', {
test_that('<dbl> == <str> :: NA_real_ == "2"', {
con <- local_con()
in_df <- tibble::tibble(x1 = NA_real_, x2 = "2")
in_rel <- duckdb:::rel_from_df(con, in_df)
Expand All @@ -1633,7 +1633,7 @@ test_that('<str> == <dbl> :: NA_real_ == "2"', {
expect_identical(out_df[, 1], NA_real_ == "2")
})

test_that('<str> == <dbl> :: 3 == NA_character_', {
test_that('<dbl> == <str> :: 3 == NA_character_', {
con <- local_con()
in_df <- tibble::tibble(x1 = 3, x2 = NA_character_)
in_rel <- duckdb:::rel_from_df(con, in_df)
Expand Down Expand Up @@ -1690,66 +1690,9 @@ test_that('<int> == <str> :: 1L == "1"', {
expect_identical(out_df[, 1], 1L == "1")
})

test_that('<int> == <str> :: "string" == NA_integer_', {
test_that('<int> == <str> :: 1L == NA_character_', {
con <- local_con()
in_df <- tibble::tibble(x1 = "string", x2 = NA_integer_)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], "string" == NA_integer_)
})

test_that('<int> == <str> :: "1" == 1L', {
con <- local_con()
in_df <- tibble::tibble(x1 = "1", x2 = 1L)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], "1" == 1L)
})

test_that('<int> == <dbl> :: 2L == 1', {
con <- local_con()
in_df <- tibble::tibble(x1 = 2L, x2 = 1)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 2L == 1)
})

test_that('<int> == <dbl> :: 1L == 1', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1L, x2 = 1)
in_df <- tibble::tibble(x1 = 1L, x2 = NA_character_)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
Expand All @@ -1763,69 +1706,12 @@ test_that('<int> == <dbl> :: 1L == 1', {
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 1L == 1)
expect_identical(out_df[, 1], 1L == NA_character_)
})

test_that('<int> == <dbl> :: NA_integer_ == 1', {
test_that('<str> == <int> :: "string" == NA_integer_', {
con <- local_con()
in_df <- tibble::tibble(x1 = NA_integer_, x2 = 1)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], NA_integer_ == 1)
})

test_that('<int> == <dbl> :: 3L == NA_real_', {
con <- local_con()
in_df <- tibble::tibble(x1 = 3L, x2 = NA_real_)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 3L == NA_real_)
})

test_that('<int> == <dbl> :: 1 == 2L', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1, x2 = 2L)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
list(duckdb:::expr_function(
'r_base::==',
list(
duckdb:::expr_reference('x1'),
duckdb:::expr_reference('x2')
)
))
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 1 == 2L)
})

test_that('<int> == <dbl> :: 1 == 1L', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1, x2 = 1L)
in_df <- tibble::tibble(x1 = "string", x2 = NA_integer_)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
Expand All @@ -1839,12 +1725,12 @@ test_that('<int> == <dbl> :: 1 == 1L', {
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 1 == 1L)
expect_identical(out_df[, 1], "string" == NA_integer_)
})

test_that('<int> == <dbl> :: 1 == NA_integer_', {
test_that('<str> == <int> :: "1" == 1L', {
con <- local_con()
in_df <- tibble::tibble(x1 = 1, x2 = NA_integer_)
in_df <- tibble::tibble(x1 = "1", x2 = 1L)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
Expand All @@ -1858,12 +1744,12 @@ test_that('<int> == <dbl> :: 1 == NA_integer_', {
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], 1 == NA_integer_)
expect_identical(out_df[, 1], "1" == 1L)
})

test_that('<int> == <dbl> :: NA_real_ == 3L', {
test_that('<str> == <int> :: NA_character_ == 2L', {
con <- local_con()
in_df <- tibble::tibble(x1 = NA_real_, x2 = 3L)
in_df <- tibble::tibble(x1 = NA_character_, x2 = 2L)
in_rel <- duckdb:::rel_from_df(con, in_df)
out_rel <- duckdb:::rel_project(
in_rel,
Expand All @@ -1877,6 +1763,6 @@ test_that('<int> == <dbl> :: NA_real_ == 3L', {
)
out_df <- duckdb:::rel_to_altrep(out_rel)

expect_identical(out_df[, 1], NA_real_ == 3L)
expect_identical(out_df[, 1], NA_character_ == 2L)
})

0 comments on commit bd61eb0

Please sign in to comment.