Skip to content

Commit 07176c3

Browse files
Add some new equivalence tests, spacing
1 parent 089e126 commit 07176c3

File tree

1 file changed

+88
-69
lines changed

1 file changed

+88
-69
lines changed

inst/tests/tests.Rraw

Lines changed: 88 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -18714,7 +18714,7 @@ test(2265.04, copy(DT)[, let(L=list(NULL))], ans)
1871418714
# using set()
1871518715
test(2265.05, set(copy(DT), j="L", value=list(NULL)), ans)
1871618716

18717-
# multiple list columns
18717+
# replacement of multiple list columns with list(NULL) in a single-row data.table, using different assignment methods
1871818718
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1871918719
ans = data.table(L1=list(NULL), L2=list(NULL), i=1L)
1872018720
DT$L1 = list(NULL)
@@ -18745,7 +18745,8 @@ test(2265.13, copy(DT)[, `:=`(L=list(NULL))], ans)
1874518745
test(2265.14, copy(DT)[, let(L=list(NULL))], ans)
1874618746
# using set()
1874718747
test(2265.15, set(copy(DT), j="L", value=list(NULL)), ans)
18748-
# tests doing the same as above, but with multiple columns
18748+
18749+
# replacement of multiple list columns with list(NULL) in a multi-row data.table, using different assignment methods
1874918750
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1875018751
ans = data.table(L1=list(NULL, NULL), L2=list(NULL, NULL), i=1L)
1875118752
DT$L1 = list(NULL)
@@ -18767,159 +18768,177 @@ ans = data.table(L=list("A"), i=1L, D=list(NULL))
1876718768
warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1876818769
# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
1876918770
test(2265.21, copy(DT)[, D := list(NULL)], DT, warning=warn)
18770-
test(2265.22, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
18771+
test(2265.22, set(copy(DT), j="D", value=NULL), DT, warning=warn)
18772+
test(2265.23, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
1877118773
# add a new column by wrapping list(NULL), consistent with old behavior
1877218774
DT$D = list(list(NULL))
18773-
test(2265.23, DT, ans)
18775+
test(2265.24, DT, ans)
1877418776
DT = data.table(L=list("A"), i=1L)
1877518777
# test adding empty list column in standard form with := operator
18776-
test(2265.24, copy(DT)[, D := .(list(NULL))], ans)
18778+
test(2265.25, copy(DT)[, D := .(list(NULL))], ans)
1877718779
# functional form with := operator
18778-
test(2265.25, copy(DT)[, `:=`(D=list(NULL))], ans)
18780+
test(2265.26, copy(DT)[, `:=`(D=list(NULL))], ans)
1877918781
# functional form with 'let' alias
18780-
test(2265.26, copy(DT)[, let(D=list(NULL))], ans)
18782+
test(2265.27, copy(DT)[, let(D=list(NULL))], ans)
1878118783
# using set()
18782-
test(2265.27, set(copy(DT), j="D", value=list(list(NULL))), ans)
18783-
# tests doing the same as above, but with multiple columns
18784+
test(2265.28, set(copy(DT), j="D", value=list(list(NULL))), ans)
18785+
18786+
# Adding multiple empty list columns to a single-row data.table, using different assignment methods
1878418787
DT = data.table(L=list("A"), i=1L)
1878518788
ans = data.table(L=list("A"), i=1L, D=list(NULL), R=list(NULL))
1878618789
DT$D = list(list(NULL))
1878718790
DT$R = list(list(NULL))
18788-
test(2265.28, DT, ans)
18791+
test(2265.29, DT, ans)
1878918792
DT = data.table(L=list("A"), i=1L)
1879018793
# standard form with := operator
18791-
test(2265.29, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18794+
test(2265.30, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18795+
test(2265.31, copy(DT)[, c("D", "R") := .(list(NULL), list(NULL))], ans)
1879218796
# functional form with := operator
18793-
test(2265.30, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
18797+
test(2265.32, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
1879418798
# functional form with 'let' alias
18795-
test(2265.31, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
18799+
test(2265.33, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
1879618800
# using set()
18797-
test(2265.32, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18801+
test(2265.34, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18802+
test(2265.35, set(copy(DT), j=c("D", "R"), value=list(list(NULL), list(NULL))), ans)
1879818803

1879918804
# Adding an empty list column to a multi-row data.table, using different assignment methods
1880018805
DT = data.table(L=list("A", "B"), i=1L)
1880118806
ans = data.table(L=list("A", "B"), i=1L, D=list(NULL, NULL))
1880218807
warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1880318808
# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
18804-
test(2265.33, copy(DT)[, D := list(NULL)], DT, warning=warn)
18805-
test(2265.34, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
18809+
test(2265.36, copy(DT)[, D := list(NULL)], DT, warning=warn)
18810+
test(2265.37, set(copy(DT), j="D", value=NULL), DT, warning=warn)
18811+
test(2265.38, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
1880618812
# add a new column by wrapping list(NULL), consistent with old behavior
1880718813
DT$D = list(list(NULL))
18808-
test(2265.35, DT, ans)
18814+
test(2265.39, DT, ans)
1880918815
DT = data.table(L=list("A", "B"), i=1L)
1881018816
# test adding empty list column in standard form with := operator
18811-
test(2265.36, copy(DT)[, D := .(list(NULL))], ans)
18817+
test(2265.40, copy(DT)[, D := .(list(NULL))], ans)
1881218818
# functional form with := operator
18813-
test(2265.37, copy(DT)[, `:=`(D=list(NULL))], ans)
18819+
test(2265.41, copy(DT)[, `:=`(D=list(NULL))], ans)
1881418820
# functional form with 'let' alias
18815-
test(2265.38, copy(DT)[, let(D=list(NULL))], ans)
18821+
test(2265.42, copy(DT)[, let(D=list(NULL))], ans)
1881618822
# using set()
18817-
test(2265.39, set(copy(DT), j="D", value = list(list(NULL))), ans)
18818-
# tests doing the same as above, but with multiple columns
18823+
test(2265.43, set(copy(DT), j="D", value = list(list(NULL))), ans)
18824+
18825+
# Adding multiply empty list columns to a multi-row data.table, using different assignment methods
1881918826
DT = data.table(L=list("A", "B"), i=1L)
1882018827
ans = data.table(L=list("A", "B"), i=1L, D=list(NULL, NULL), R=list(NULL, NULL))
1882118828
DT$D = list(list(NULL))
1882218829
DT$R = list(list(NULL))
18823-
test(2265.40, DT, ans)
18830+
test(2265.44, DT, ans)
1882418831
DT = data.table(L=list("A", "B"), i=1L)
1882518832
# standard form with := operator
18826-
test(2265.41, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18833+
test(2265.45, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18834+
test(2265.46, copy(DT)[, c("D", "R") := .(list(NULL), list(NULL))], ans)
1882718835
# functional form with := operator
18828-
test(2265.42, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
18836+
test(2265.47, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
1882918837
# functional form with 'let' alias
18830-
test(2265.43, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
18838+
test(2265.48, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
1883118839
# using set()
18832-
test(2265.44, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18840+
test(2265.49, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18841+
test(2265.50, set(copy(DT), j=c("D", "R"), value=list(list(NULL), list(NULL))), ans)
1883318842

1883418843
# Removal of a list column in a single-row data.table, using different assignment methods
1883518844
# NOTE: There is only one way to remove columns now, by assigning to NULL
1883618845
DT = data.table(L=list("A"), i=1L)
1883718846
ans = data.table(i=1L)
1883818847
# test removing a list column by assigning to NULL
1883918848
DT$L = NULL
18840-
test(2265.45, DT, ans)
18849+
test(2265.51, DT, ans)
1884118850
DT = data.table(L=list("A"), i=1L)
1884218851
# standard form with := operator
18843-
test(2265.46, copy(DT)[, L := NULL], ans)
18852+
test(2265.52, copy(DT)[, L := NULL], ans)
1884418853
# functional form with := operator
18845-
test(2265.47, copy(DT)[, `:=`(L=NULL)], ans)
18854+
test(2265.53, copy(DT)[, `:=`(L=NULL)], ans)
1884618855
# functional form with 'let' alias
18847-
test(2265.48, copy(DT)[, let(L=NULL)], ans)
18856+
test(2265.54, copy(DT)[, let(L=NULL)], ans)
1884818857
# using set()
18849-
test(2265.49, set(copy(DT), j="L", value=NULL), ans)
18850-
# test doing the same as above, but with multiple columns
18858+
test(2265.55, set(copy(DT), j="L", value=NULL), ans)
18859+
18860+
# Removal of multiple list columns in a single-row data.table, using different assignment methods
1885118861
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1885218862
# test removing two list columns by assigning to NULL
1885318863
DT$L1 = NULL
1885418864
DT$L2 = NULL
18855-
test(2265.50, DT, ans)
18865+
test(2265.56, DT, ans)
1885618866
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1885718867
# standard form with := operator
18858-
test(2265.51, copy(DT)[, c("L1", "L2") := NULL], ans)
18868+
test(2265.57, copy(DT)[, c("L1", "L2") := NULL], ans)
18869+
test(2265.58, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
1885918870
# functional form with := operator
18860-
test(2265.52, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
18871+
test(2265.59, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
1886118872
# functional form with 'let' alias
18862-
test(2265.53, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
18873+
test(2265.60, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
1886318874
# using set()
18864-
test(2265.54, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18875+
test(2265.61, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18876+
test(2265.62, set(copy(DT), j=c("L1", "L2"), value=list(NULL, NULL)), ans)
1886518877

1886618878
# Removal of a list column in a multi-row data.table, using different assignment methods
1886718879
DT = data.table(L=list("A", "B"), i=1L)
1886818880
ans = data.table(i=c(1L, 1L))
1886918881
# test removing a list column by assigning to NULL
1887018882
DT$L = NULL
18871-
test(2265.55, DT, ans)
18883+
test(2265.63, DT, ans)
1887218884
DT = data.table(L=list("A", "B"), i=1L)
1887318885
# standard form with := operator
18874-
test(2265.56, copy(DT)[, L := NULL], ans)
18886+
test(2265.64, copy(DT)[, L := NULL], ans)
1887518887
# functional form with := operator
18876-
test(2265.57, copy(DT)[, `:=`(L=NULL)], ans)
18888+
test(2265.65, copy(DT)[, `:=`(L=NULL)], ans)
1887718889
# functional form with 'let' alias
18878-
test(2265.58, copy(DT)[, let(L=NULL)], ans)
18890+
test(2265.66, copy(DT)[, let(L=NULL)], ans)
1887918891
# using set()
18880-
test(2265.59, set(copy(DT), j="L", value=NULL), ans)
18881-
# test doing the same as above, but with multiple columns
18892+
test(2265.67, set(copy(DT), j="L", value=NULL), ans)
18893+
18894+
# Removal of multiple list columns in a multi-row data.table, using different assignment methods
1888218895
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1888318896
# test removing two list columns by assigning to NULL
1888418897
DT$L1 = NULL
1888518898
DT$L2 = NULL
18886-
test(2265.60, DT, ans)
18899+
test(2265.68, DT, ans)
1888718900
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1888818901
# standard form with := operator
18889-
test(2265.61, copy(DT)[, c("L1", "L2") := NULL], ans)
18902+
test(2265.69, copy(DT)[, c("L1", "L2") := NULL], ans)
18903+
test(2265.70, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
1889018904
# functional form with := operator
18891-
test(2265.62, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
18905+
test(2265.71, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
1889218906
# functional form with 'let' alias
18893-
test(2265.63, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
18907+
test(2265.72, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
1889418908
# using set()
18895-
test(2265.64, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18909+
test(2265.73, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18910+
test(2265.74, set(copy(DT), j=c("L1", "L2"), value=list(NULL, NULL)), ans)
1889618911

1889718912
# Combining queries (add/remove/replace columns in the same query) for a single-row data.table
18898-
DT = data.table(L=list("A"), i=1L)
18913+
1889918914
# test for adding a new empty list column D and removing column L in the same query
18900-
ans = data.table(i=1L, D=list(NULL))
18901-
test(2265.65, copy(DT)[, c("L", "D") := list(NULL, list(NULL))], ans)
18902-
test(2265.66, copy(DT)[, `:=`(L=NULL, D=list(NULL))], ans)
18903-
test(2265.67, copy(DT)[, let(L=NULL, D=list(NULL))], ans)
18904-
test(2265.68, set(copy(DT), j=c("L", "D"), value=list(NULL, list(NULL))), ans)
1890518915
DT = data.table(L=list("A"), i=1L)
18916+
ans = data.table(i=1L, D=list(NULL))
18917+
test(2265.75, copy(DT)[, c("L", "D") := list(NULL, list(NULL))], ans)
18918+
test(2265.76, copy(DT)[, `:=`(L=NULL, D=list(NULL))], ans)
18919+
test(2265.77, copy(DT)[, let(L=NULL, D=list(NULL))], ans)
18920+
test(2265.78, set(copy(DT), j=c("L", "D"), value=list(NULL, list(NULL))), ans)
18921+
1890618922
# test for adding a new empty list column D and replacing column L with empty list in the same query
18923+
DT = data.table(L=list("A"), i=1L)
1890718924
ans = data.table(L=list(NULL), i=1L, D=list(NULL))
18908-
test(2265.69, copy(DT)[, c("L", "D") := list(list(NULL), list(NULL))], ans)
18909-
test(2265.70, copy(DT)[, `:=`(L=list(NULL), D=list(NULL))], ans)
18910-
test(2265.71, copy(DT)[, let(L=list(NULL), D=list(NULL))], ans)
18911-
test(2265.72, set(copy(DT), j=c("L", "D"), value=list(list(NULL), list(NULL))), ans)
18912-
DT = data.table(L=list("A"), D=list("B"), i=1L)
18925+
test(2265.79, copy(DT)[, c("L", "D") := list(list(NULL), list(NULL))], ans)
18926+
test(2265.80, copy(DT)[, `:=`(L=list(NULL), D=list(NULL))], ans)
18927+
test(2265.81, copy(DT)[, let(L=list(NULL), D=list(NULL))], ans)
18928+
test(2265.82, set(copy(DT), j=c("L", "D"), value=list(list(NULL), list(NULL))), ans)
18929+
1891318930
# test for replacing column L with an empty list and removing list column D in the same query
18914-
ans = data.table(L=list(NULL), i=1L)
18915-
test(2265.73, copy(DT)[, c("L", "D") := list(list(NULL), NULL)], ans)
18916-
test(2265.74, copy(DT)[, `:=`(L=list(NULL), D=NULL)], ans)
18917-
test(2265.75, copy(DT)[, let(L=list(NULL), D=NULL)], ans)
18918-
test(2265.76, set(copy(DT), j=c("L", "D"), value=list(list(NULL), NULL)), ans)
1891918931
DT = data.table(L=list("A"), D=list("B"), i=1L)
18932+
ans = data.table(L=list(NULL), i=1L)
18933+
test(2265.83, copy(DT)[, c("L", "D") := list(list(NULL), NULL)], ans)
18934+
test(2265.84, copy(DT)[, `:=`(L=list(NULL), D=NULL)], ans)
18935+
test(2265.85, copy(DT)[, let(L=list(NULL), D=NULL)], ans)
18936+
test(2265.86, set(copy(DT), j=c("L", "D"), value=list(list(NULL), NULL)), ans)
18937+
1892018938
# test for combining add, replace, remove in the same query
18939+
DT = data.table(L=list("A"), D=list("B"), i=1L)
1892118940
ans = data.table(L=list(NULL), i=1L, E=list(NULL))
18922-
test(2265.77, copy(DT)[, c("L", "D", "E") := list(list(NULL), NULL, list(NULL))], ans)
18923-
test(2265.78, copy(DT)[, `:=`(L=list(NULL), D=NULL, E=list(NULL))], ans)
18924-
test(2265.79, copy(DT)[, let(L=list(NULL), D=NULL, E=list(NULL))], ans)
18925-
test(2265.80, set(copy(DT), j=c("L", "D", "E"), value=list(list(NULL), NULL, list(NULL))), ans)
18941+
test(2265.87, copy(DT)[, c("L", "D", "E") := list(list(NULL), NULL, list(NULL))], ans)
18942+
test(2265.88, copy(DT)[, `:=`(L=list(NULL), D=NULL, E=list(NULL))], ans)
18943+
test(2265.89, copy(DT)[, let(L=list(NULL), D=NULL, E=list(NULL))], ans)
18944+
test(2265.90, set(copy(DT), j=c("L", "D", "E"), value=list(list(NULL), NULL, list(NULL))), ans)

0 commit comments

Comments
 (0)