File: test-python-comparisons.R

package info (click to toggle)
r-cran-reticulate 1.41.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,088 kB
  • sloc: cpp: 5,154; python: 620; sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
context("comparisons")

test_that("Python integers can be compared", {
  skip_if_no_python()
  builtins <- import_builtins(convert = FALSE)
  a <- builtins$int(1)
  b <- builtins$int(2)
  expect_true(py_bool(a < b))
  expect_true(py_bool(b > a))
  expect_true(py_bool(a == a))
  expect_true(py_bool(a != b))
  expect_true(py_bool(a <= 1L))
  expect_true(py_bool(b >= 2L))
})

test_that("Python objects with the same reference are equal", {
  skip_if_no_python()
  list_fn1 <- import_builtins(convert = FALSE)$list
  list_fn2 <- import_builtins(convert = TRUE)$list

  expect_true(py_bool(list_fn1 == list_fn2))
})