Skip to content

Commit

Permalink
Tests on corrected behavior for integer64/double (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Oct 20, 2024
1 parent 861a1d1 commit 4affcf5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-integer64.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ test_that("semantics about mixed types for multiplication are respected", {
expect_identical(i64 * int, as.integer64(10L))
expect_identical(int * i64, as.integer64(10L))
expect_identical(i64 * i64, as.integer64(4L))

withr::with_options(list(integer64_semantics = "new"), {
expect_identical(i64 * dbl, as.integer64(7L))
expect_identical(dbl * i64, as.integer64(7L))
Expand All @@ -249,3 +250,24 @@ test_that("semantics about mixed types for multiplication are respected", {
expect_identical(i64 * i64, as.integer64(4L))
})
})

test_that("semantics about mixed types for division are respected", {
int = 10L
i64 = as.integer64(5L)
dbl = 2.5

# default: "old" semantics, to be deprecated
expect_identical(i64 / dbl, 2.0)
expect_identical(dbl / i64, 0.4)
expect_identical(i64 / int, 0.5)
expect_identical(int / i64, 2.0)
expect_identical(i64 / i64, 1.0)

withr::with_options(list(integer64_semantics = "new"), {
expect_identical(i64 / dbl, 2.0)
expect_identical(dbl / i64, 0.5)
expect_identical(i64 / int, 0.5)
expect_identical(int / i64, 2.0)
expect_identical(i64 / i64, 1.0)
})
})

0 comments on commit 4affcf5

Please sign in to comment.