Skip to content

Commit 9e1260f

Browse files
committed
Test that format.<column>() is disregarded
1 parent 26c71c5 commit 9e1260f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

inst/tests/tests.Rraw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16770,15 +16770,15 @@ registerS3method("format_col", "complex", format_col.default)
1677016770
# then i) test 1610.1 fails if test.data.table() is rerun, ii) user display of complex data would be affected
1677116771
# did try wrapping with on.exit(,add=TRUE) but perhaps because this is a script that is sys.source'd, it ran straight away
1677216772

16773-
# format method for column takes predecedence over format method for each list item
16773+
# as of #6637, format individual list items but not the whole list
1677416774
registerS3method("format", "myclass2130", function(x, ...) paste0("<", class(x)[1L], ":", x$id, ">"))
1677516775
DT = data.table(row=1:2, objs=list(structure(list(id="foo"), class="myclass2130"), structure(list(id="bar"), class="myclass2130")))
1677616776
test(2130.13, print(DT), output="myclass2130:foo.*myclass2130:bar")
1677716777
setattr(DT$objs, "class", "foo2130")
1677816778
registerS3method("format", "foo2130", function(x, ...) "All hail foo")
1677916779
test(2130.14, print(DT), output="myclass2130:foo.*myclass2130:bar") # because length 1 from format but needs to be length(x)
1678016780
registerS3method("format", "foo2130", function(x, ...) rep("All hail foo",length(x)))
16781-
test(2130.15, print(DT), output="All hail foo") # e.g. sf:::format.sfc rather than sf:::format.sfg on each item
16781+
test(2130.15, print(DT), output="myclass2130:foo.*myclass2130:bar") # used to call format(column), not vapply_1c(column, format)
1678216782
setattr(DT$objs, "class", "bar2130_with_no_method")
1678316783
test(2130.16, print(DT), output="myclass2130:foo.*myclass2130:bar")
1678416784
registerS3method("format", "myclass2130", format.default)

0 commit comments

Comments
 (0)