Skip to content

Commit 05fc065

Browse files
Add tests of sub-assignment
1 parent 07176c3 commit 05fc065

File tree

1 file changed

+122
-90
lines changed

1 file changed

+122
-90
lines changed

inst/tests/tests.Rraw

Lines changed: 122 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -18703,242 +18703,274 @@ DT = data.table(L=list("A"), i=1L)
1870318703
ans = data.table(L=list(NULL), i=1L)
1870418704
# test using replacement with $ operator
1870518705
DT$L = list(NULL)
18706-
test(2265.01, DT, ans)
18706+
test(2265.001, DT, ans)
1870718707
DT = data.table(L=list("A"), i=1L)
1870818708
# standard form with := operator
18709-
test(2265.02, copy(DT)[, L := list(NULL)], ans)
18709+
test(2265.002, copy(DT)[, L := list(NULL)], ans)
1871018710
# functional form with := operator
18711-
test(2265.03, copy(DT)[, `:=`(L=list(NULL))], ans)
18711+
test(2265.003, copy(DT)[, `:=`(L=list(NULL))], ans)
1871218712
# functional form with 'let' alias
18713-
test(2265.04, copy(DT)[, let(L=list(NULL))], ans)
18713+
test(2265.004, copy(DT)[, let(L=list(NULL))], ans)
1871418714
# using set()
18715-
test(2265.05, set(copy(DT), j="L", value=list(NULL)), ans)
18715+
test(2265.005, set(copy(DT), j="L", value=list(NULL)), ans)
1871618716

1871718717
# 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)
1872118721
DT$L2 = list(NULL)
18722-
test(2265.06, DT, ans)
18722+
test(2265.006, DT, ans)
1872318723
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1872418724
# standard form with := operator
18725-
test(2265.07, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
18725+
test(2265.007, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
1872618726
# functional form with := operator
18727-
test(2265.08, copy(DT)[, `:=`(L1=list(NULL), L2=list(NULL))], ans)
18727+
test(2265.008, copy(DT)[, `:=`(L1=list(NULL), L2=list(NULL))], ans)
1872818728
# functional form with 'let' alias
18729-
test(2265.09, copy(DT)[, let(L1=list(NULL), L2=list(NULL))], ans)
18729+
test(2265.009, copy(DT)[, let(L1=list(NULL), L2=list(NULL))], ans)
1873018730
# using set()
18731-
test(2265.10, set(copy(DT), j=c("L1", "L2"), value=list(list(NULL), list(NULL))), ans)
18731+
test(2265.010, set(copy(DT), j=c("L1", "L2"), value=list(list(NULL), list(NULL))), ans)
1873218732

1873318733
# replacement of a list column with list(NULL) in a multi-row data.table, using different assignment methods
1873418734
DT = data.table(L=list("A", "B"), i=1L)
1873518735
ans = data.table(L=list(NULL, NULL), i=1L)
1873618736
# test using replacement with $ operator
1873718737
DT$L = list(NULL)
18738-
test(2265.11, DT, ans)
18738+
test(2265.011, DT, ans)
1873918739
DT = data.table(L=list("A", "B"), i=1L)
1874018740
# standard form with := operator
18741-
test(2265.12, copy(DT)[, L := list(NULL)], ans)
18741+
test(2265.012, copy(DT)[, L := list(NULL)], ans)
1874218742
# functional form with := operator
18743-
test(2265.13, copy(DT)[, `:=`(L=list(NULL))], ans)
18743+
test(2265.013, copy(DT)[, `:=`(L=list(NULL))], ans)
1874418744
# functional form with 'let' alias
18745-
test(2265.14, copy(DT)[, let(L=list(NULL))], ans)
18745+
test(2265.014, copy(DT)[, let(L=list(NULL))], ans)
1874618746
# using set()
18747-
test(2265.15, set(copy(DT), j="L", value=list(NULL)), ans)
18747+
test(2265.015, set(copy(DT), j="L", value=list(NULL)), ans)
1874818748

1874918749
# replacement of multiple list columns with list(NULL) in a multi-row data.table, using different assignment methods
1875018750
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1875118751
ans = data.table(L1=list(NULL, NULL), L2=list(NULL, NULL), i=1L)
1875218752
DT$L1 = list(NULL)
1875318753
DT$L2 = list(NULL)
18754-
test(2265.16, DT, ans)
18754+
test(2265.016, DT, ans)
1875518755
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1875618756
# standard form with := operator
18757-
test(2265.17, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
18757+
test(2265.017, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
1875818758
# functional form with := operator
18759-
test(2265.18, copy(DT)[, `:=`(L1=list(NULL), L2=list(NULL))], ans)
18759+
test(2265.018, copy(DT)[, `:=`(L1=list(NULL), L2=list(NULL))], ans)
1876018760
# functional form with 'let' alias
18761-
test(2265.19, copy(DT)[, let(L1=list(NULL), L2=list(NULL))], ans)
18761+
test(2265.019, copy(DT)[, let(L1=list(NULL), L2=list(NULL))], ans)
1876218762
# using set()
18763-
test(2265.20, set(copy(DT), j=c("L1", "L2"), value=list(list(NULL), list(NULL))), ans)
18763+
test(2265.020, set(copy(DT), j=c("L1", "L2"), value=list(list(NULL), list(NULL))), ans)
1876418764

1876518765
# Adding an empty list column to a single-row data.table, using different assignment methods
1876618766
DT = data.table(L=list("A"), i=1L)
1876718767
ans = data.table(L=list("A"), i=1L, D=list(NULL))
1876818768
warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1876918769
# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
18770-
test(2265.21, copy(DT)[, D := 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)
18770+
test(2265.021, copy(DT)[, D := list(NULL)], DT, warning=warn)
18771+
test(2265.022, set(copy(DT), j="D", value=NULL), DT, warning=warn)
18772+
test(2265.023, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
1877318773
# add a new column by wrapping list(NULL), consistent with old behavior
1877418774
DT$D = list(list(NULL))
18775-
test(2265.24, DT, ans)
18775+
test(2265.024, DT, ans)
1877618776
DT = data.table(L=list("A"), i=1L)
1877718777
# test adding empty list column in standard form with := operator
18778-
test(2265.25, copy(DT)[, D := .(list(NULL))], ans)
18778+
test(2265.025, copy(DT)[, D := .(list(NULL))], ans)
1877918779
# functional form with := operator
18780-
test(2265.26, copy(DT)[, `:=`(D=list(NULL))], ans)
18780+
test(2265.026, copy(DT)[, `:=`(D=list(NULL))], ans)
1878118781
# functional form with 'let' alias
18782-
test(2265.27, copy(DT)[, let(D=list(NULL))], ans)
18782+
test(2265.027, copy(DT)[, let(D=list(NULL))], ans)
1878318783
# using set()
18784-
test(2265.28, set(copy(DT), j="D", value=list(list(NULL))), ans)
18784+
test(2265.028, set(copy(DT), j="D", value=list(list(NULL))), ans)
1878518785

1878618786
# Adding multiple empty list columns to a single-row data.table, using different assignment methods
1878718787
DT = data.table(L=list("A"), i=1L)
1878818788
ans = data.table(L=list("A"), i=1L, D=list(NULL), R=list(NULL))
1878918789
DT$D = list(list(NULL))
1879018790
DT$R = list(list(NULL))
18791-
test(2265.29, DT, ans)
18791+
test(2265.029, DT, ans)
1879218792
DT = data.table(L=list("A"), i=1L)
1879318793
# standard form with := operator
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)
18794+
test(2265.030, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18795+
test(2265.031, copy(DT)[, c("D", "R") := .(list(NULL), list(NULL))], ans)
1879618796
# functional form with := operator
18797-
test(2265.32, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
18797+
test(2265.032, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
1879818798
# functional form with 'let' alias
18799-
test(2265.33, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
18799+
test(2265.033, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
1880018800
# using set()
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)
18801+
test(2265.034, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18802+
test(2265.035, set(copy(DT), j=c("D", "R"), value=list(list(NULL), list(NULL))), ans)
1880318803

1880418804
# Adding an empty list column to a multi-row data.table, using different assignment methods
1880518805
DT = data.table(L=list("A", "B"), i=1L)
1880618806
ans = data.table(L=list("A", "B"), i=1L, D=list(NULL, NULL))
1880718807
warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1880818808
# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
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)
18809+
test(2265.036, copy(DT)[, D := list(NULL)], DT, warning=warn)
18810+
test(2265.037, set(copy(DT), j="D", value=NULL), DT, warning=warn)
18811+
test(2265.038, set(copy(DT), j="D", value=list(NULL)), DT, warning=warn)
1881218812
# add a new column by wrapping list(NULL), consistent with old behavior
1881318813
DT$D = list(list(NULL))
18814-
test(2265.39, DT, ans)
18814+
test(2265.039, DT, ans)
1881518815
DT = data.table(L=list("A", "B"), i=1L)
1881618816
# test adding empty list column in standard form with := operator
18817-
test(2265.40, copy(DT)[, D := .(list(NULL))], ans)
18817+
test(2265.040, copy(DT)[, D := .(list(NULL))], ans)
1881818818
# functional form with := operator
18819-
test(2265.41, copy(DT)[, `:=`(D=list(NULL))], ans)
18819+
test(2265.041, copy(DT)[, `:=`(D=list(NULL))], ans)
1882018820
# functional form with 'let' alias
18821-
test(2265.42, copy(DT)[, let(D=list(NULL))], ans)
18821+
test(2265.042, copy(DT)[, let(D=list(NULL))], ans)
1882218822
# using set()
18823-
test(2265.43, set(copy(DT), j="D", value = list(list(NULL))), ans)
18823+
test(2265.043, set(copy(DT), j="D", value = list(list(NULL))), ans)
1882418824

1882518825
# Adding multiply empty list columns to a multi-row data.table, using different assignment methods
1882618826
DT = data.table(L=list("A", "B"), i=1L)
1882718827
ans = data.table(L=list("A", "B"), i=1L, D=list(NULL, NULL), R=list(NULL, NULL))
1882818828
DT$D = list(list(NULL))
1882918829
DT$R = list(list(NULL))
18830-
test(2265.44, DT, ans)
18830+
test(2265.044, DT, ans)
1883118831
DT = data.table(L=list("A", "B"), i=1L)
1883218832
# standard form with := operator
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)
18833+
test(2265.045, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
18834+
test(2265.046, copy(DT)[, c("D", "R") := .(list(NULL), list(NULL))], ans)
1883518835
# functional form with := operator
18836-
test(2265.47, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
18836+
test(2265.047, copy(DT)[, `:=`(D=list(NULL), R=list(NULL))], ans)
1883718837
# functional form with 'let' alias
18838-
test(2265.48, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
18838+
test(2265.048, copy(DT)[, let(D=list(NULL), R=list(NULL))], ans)
1883918839
# using set()
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)
18840+
test(2265.049, set(copy(DT), j=c("D", "R"), value=list(list(NULL))), ans)
18841+
test(2265.050, set(copy(DT), j=c("D", "R"), value=list(list(NULL), list(NULL))), ans)
1884218842

1884318843
# Removal of a list column in a single-row data.table, using different assignment methods
1884418844
# NOTE: There is only one way to remove columns now, by assigning to NULL
1884518845
DT = data.table(L=list("A"), i=1L)
1884618846
ans = data.table(i=1L)
1884718847
# test removing a list column by assigning to NULL
1884818848
DT$L = NULL
18849-
test(2265.51, DT, ans)
18849+
test(2265.051, DT, ans)
1885018850
DT = data.table(L=list("A"), i=1L)
1885118851
# standard form with := operator
18852-
test(2265.52, copy(DT)[, L := NULL], ans)
18852+
test(2265.052, copy(DT)[, L := NULL], ans)
1885318853
# functional form with := operator
18854-
test(2265.53, copy(DT)[, `:=`(L=NULL)], ans)
18854+
test(2265.053, copy(DT)[, `:=`(L=NULL)], ans)
1885518855
# functional form with 'let' alias
18856-
test(2265.54, copy(DT)[, let(L=NULL)], ans)
18856+
test(2265.054, copy(DT)[, let(L=NULL)], ans)
1885718857
# using set()
18858-
test(2265.55, set(copy(DT), j="L", value=NULL), ans)
18858+
test(2265.055, set(copy(DT), j="L", value=NULL), ans)
1885918859

1886018860
# Removal of multiple list columns in a single-row data.table, using different assignment methods
1886118861
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1886218862
# test removing two list columns by assigning to NULL
1886318863
DT$L1 = NULL
1886418864
DT$L2 = NULL
18865-
test(2265.56, DT, ans)
18865+
test(2265.056, DT, ans)
1886618866
DT = data.table(L1=list("A"), L2=list("B"), i=1L)
1886718867
# standard form with := operator
18868-
test(2265.57, copy(DT)[, c("L1", "L2") := NULL], ans)
18869-
test(2265.58, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
18868+
test(2265.057, copy(DT)[, c("L1", "L2") := NULL], ans)
18869+
test(2265.058, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
1887018870
# functional form with := operator
18871-
test(2265.59, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
18871+
test(2265.059, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
1887218872
# functional form with 'let' alias
18873-
test(2265.60, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
18873+
test(2265.060, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
1887418874
# using set()
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)
18875+
test(2265.061, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18876+
test(2265.062, set(copy(DT), j=c("L1", "L2"), value=list(NULL, NULL)), ans)
1887718877

1887818878
# Removal of a list column in a multi-row data.table, using different assignment methods
1887918879
DT = data.table(L=list("A", "B"), i=1L)
1888018880
ans = data.table(i=c(1L, 1L))
1888118881
# test removing a list column by assigning to NULL
1888218882
DT$L = NULL
18883-
test(2265.63, DT, ans)
18883+
test(2265.063, DT, ans)
1888418884
DT = data.table(L=list("A", "B"), i=1L)
1888518885
# standard form with := operator
18886-
test(2265.64, copy(DT)[, L := NULL], ans)
18886+
test(2265.064, copy(DT)[, L := NULL], ans)
1888718887
# functional form with := operator
18888-
test(2265.65, copy(DT)[, `:=`(L=NULL)], ans)
18888+
test(2265.065, copy(DT)[, `:=`(L=NULL)], ans)
1888918889
# functional form with 'let' alias
18890-
test(2265.66, copy(DT)[, let(L=NULL)], ans)
18890+
test(2265.066, copy(DT)[, let(L=NULL)], ans)
1889118891
# using set()
18892-
test(2265.67, set(copy(DT), j="L", value=NULL), ans)
18892+
test(2265.067, set(copy(DT), j="L", value=NULL), ans)
1889318893

1889418894
# Removal of multiple list columns in a multi-row data.table, using different assignment methods
1889518895
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1889618896
# test removing two list columns by assigning to NULL
1889718897
DT$L1 = NULL
1889818898
DT$L2 = NULL
18899-
test(2265.68, DT, ans)
18899+
test(2265.068, DT, ans)
1890018900
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
1890118901
# standard form with := operator
18902-
test(2265.69, copy(DT)[, c("L1", "L2") := NULL], ans)
18903-
test(2265.70, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
18902+
test(2265.069, copy(DT)[, c("L1", "L2") := NULL], ans)
18903+
test(2265.070, copy(DT)[, c("L1", "L2") := .(NULL, NULL)], ans)
1890418904
# functional form with := operator
18905-
test(2265.71, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
18905+
test(2265.071, copy(DT)[, `:=`(L1=NULL, L2=NULL)], ans)
1890618906
# functional form with 'let' alias
18907-
test(2265.72, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
18907+
test(2265.072, copy(DT)[, let(L1=NULL, L2=NULL)], ans)
1890818908
# using set()
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)
18909+
test(2265.073, set(copy(DT), j=c("L1", "L2"), value=NULL), ans)
18910+
test(2265.074, set(copy(DT), j=c("L1", "L2"), value=list(NULL, NULL)), ans)
1891118911

1891218912
# Combining queries (add/remove/replace columns in the same query) for a single-row data.table
1891318913

1891418914
# test for adding a new empty list column D and removing column L in the same query
1891518915
DT = data.table(L=list("A"), i=1L)
1891618916
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)
18917+
test(2265.075, copy(DT)[, c("L", "D") := list(NULL, list(NULL))], ans)
18918+
test(2265.076, copy(DT)[, `:=`(L=NULL, D=list(NULL))], ans)
18919+
test(2265.077, copy(DT)[, let(L=NULL, D=list(NULL))], ans)
18920+
test(2265.078, set(copy(DT), j=c("L", "D"), value=list(NULL, list(NULL))), ans)
1892118921

1892218922
# test for adding a new empty list column D and replacing column L with empty list in the same query
1892318923
DT = data.table(L=list("A"), i=1L)
1892418924
ans = data.table(L=list(NULL), i=1L, D=list(NULL))
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)
18925+
test(2265.079, copy(DT)[, c("L", "D") := list(list(NULL), list(NULL))], ans)
18926+
test(2265.080, copy(DT)[, `:=`(L=list(NULL), D=list(NULL))], ans)
18927+
test(2265.081, copy(DT)[, let(L=list(NULL), D=list(NULL))], ans)
18928+
test(2265.082, set(copy(DT), j=c("L", "D"), value=list(list(NULL), list(NULL))), ans)
1892918929

1893018930
# test for replacing column L with an empty list and removing list column D in the same query
1893118931
DT = data.table(L=list("A"), D=list("B"), i=1L)
1893218932
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)
18933+
test(2265.083, copy(DT)[, c("L", "D") := list(list(NULL), NULL)], ans)
18934+
test(2265.084, copy(DT)[, `:=`(L=list(NULL), D=NULL)], ans)
18935+
test(2265.085, copy(DT)[, let(L=list(NULL), D=NULL)], ans)
18936+
test(2265.086, set(copy(DT), j=c("L", "D"), value=list(list(NULL), NULL)), ans)
1893718937

1893818938
# test for combining add, replace, remove in the same query
1893918939
DT = data.table(L=list("A"), D=list("B"), i=1L)
1894018940
ans = data.table(L=list(NULL), i=1L, E=list(NULL))
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)
18941+
test(2265.087, copy(DT)[, c("L", "D", "E") := list(list(NULL), NULL, list(NULL))], ans)
18942+
test(2265.088, copy(DT)[, `:=`(L=list(NULL), D=NULL, E=list(NULL))], ans)
18943+
test(2265.089, copy(DT)[, let(L=list(NULL), D=NULL, E=list(NULL))], ans)
18944+
test(2265.090, set(copy(DT), j=c("L", "D", "E"), value=list(list(NULL), NULL, list(NULL))), ans)
18945+
18946+
# sub-assignment of list column with list(NULL) in a multi-row data.table, using different assignment methods
18947+
DT = data.table(L=list("A", "B"), i=1L)
18948+
ans = data.table(L=list("A", NULL), i=1L)
18949+
# test using replacement with $ operator
18950+
DT$L[2L] = list(NULL)
18951+
test(2265.091, DT, ans)
18952+
DT = data.table(L=list("A", "B"), i=1L)
18953+
# standard form with := operator
18954+
test(2265.092, copy(DT)[2L, L := list(NULL)], ans)
18955+
# functional form with := operator
18956+
test(2265.093, copy(DT)[2L, `:=`(L=list(NULL))], ans)
18957+
# functional form with 'let' alias
18958+
test(2265.094, copy(DT)[2L, let(L=list(NULL))], ans)
18959+
# using set()
18960+
test(2265.095, set(copy(DT), i=2L, j="L", value=list(NULL)), ans)
18961+
18962+
# sub-assignment of multiple list columns with list(NULL) in a multi-row data.table, using different assignment methods
18963+
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
18964+
ans = data.table(L1=list("A", NULL), L2=list("B", NULL), i=1L)
18965+
DT$L1[2L] = list(NULL)
18966+
DT$L2[2L] = list(NULL)
18967+
test(2265.096, DT, ans)
18968+
DT = data.table(L1=list("A", "B"), L2=list("B", "C"), i=1L)
18969+
# standard form with := operator
18970+
test(2265.097, copy(DT)[2L, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
18971+
# functional form with := operator
18972+
test(2265.098, copy(DT)[2L, `:=`(L1=list(NULL), L2=list(NULL))], ans)
18973+
# functional form with 'let' alias
18974+
test(2265.099, copy(DT)[2L, let(L1=list(NULL), L2=list(NULL))], ans)
18975+
# using set()
18976+
test(2265.100, set(copy(DT), i=2L, j=c("L1", "L2"), value=list(list(NULL), list(NULL))), ans)

0 commit comments

Comments
 (0)