Skip to content

Commit 7ed6c27

Browse files
committed
fix print method, closes #64
1 parent 061fe6f commit 7ed6c27

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: errors
22
Type: Package
33
Title: Uncertainty Propagation for R Vectors
4-
Version: 0.4.4
4+
Version: 0.4.4.1
55
Authors@R: c(
66
person("Iñaki", "Ucar", email="[email protected]",
77
role=c("aut", "cph", "cre"), comment=c(ORCID="0000-0001-6403-5550")),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# errors devel
2+
3+
- Fix `print()` method, which now correctly returns the object invisibly (#64).
4+
15
# errors 0.4.4
26

37
- Improve `cbind` arg name deparsing.

R/print.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ print.errors <- function(x, ...) {
116116
if (length(err) > 5L)
117117
e <- paste(e, "...")
118118
cat("Errors: ", e, "\n", sep = "")
119-
x <- drop_errors(x)
120-
NextMethod()
119+
x_next <- drop_errors(x)
120+
print(x_next, ...)
121121
} else {
122122
cat(format(x, ...), "\n", sep="")
123-
invisible(x)
124123
}
124+
invisible(x)
125125
}

tests/testthat/test-print.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ test_that("error formatting works properly", {
6565
expect_equal(format(x), c("0.0(1)e12", "1.0(1)e12"))
6666
expect_equal(format(x, digits=2), c("0.00(10)e12", "1.00(10)e12"))
6767
})
68+
69+
test_that("print method returns the object invisibly", {
70+
x <- set_errors(1:4, seq(0.1, 0.4, 0.1))
71+
72+
expect_output(x1 <- print(x))
73+
expect_identical(x, x1)
74+
})

0 commit comments

Comments
 (0)