@@ -7,33 +7,57 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
77 expect_error(ts_load(" nonexistent_ts" ))
88 ts_file <- system.file(" examples/test.trees" , package = " RcppTskit" )
99
10+ expect_error(
11+ ts_ptr_load(ts_file , options = bitwShiftL(1L , 30 )),
12+ regexp = " ts_ptr_load only supports load options"
13+ # TSK_LOAD_SKIP_TABLES (1 << 0) and TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
14+ )
15+
16+ # TSK_LOAD_SKIP_TABLES (1 << 0)
1017 expect_error(
1118 ts_load(ts_file , skip_tables = " y" ),
1219 regexp = " skip_tables must be TRUE/FALSE!"
1320 )
14- expect_no_error(tc_load(ts_file , skip_tables = TRUE ))
21+ expect_no_error(ts_ptr_load(ts_file , options = bitwShiftL(1L , 0L )))
22+ expect_no_error(ts_load(ts_file , skip_tables = TRUE ))
23+ check_empty_tables_ptr <- function (ts ) {
24+ # jarl-ignore implicit_assignment: it's just a test
25+ tmp <- capture.output(p <- ts_ptr_print(ts ))
26+ expect_true(all(p $ tables $ number == 0 ))
27+ }
1528 check_empty_tables <- function (ts ) {
1629 # jarl-ignore implicit_assignment: it's just a test
1730 tmp <- capture.output(p <- ts $ print())
1831 expect_true(all(p $ tables $ number == 0 ))
1932 }
33+ ts_ptr <- ts_ptr_load(ts_file , options = bitwShiftL(1L , 0L ))
34+ check_empty_tables_ptr(ts_ptr )
2035 ts <- ts_load(ts_file , skip_tables = TRUE )
2136 check_empty_tables(ts )
22- ts <- TableCollection $ new(file = ts_file , skip_tables = TRUE )
37+ ts <- TreeSequence $ new(file = ts_file , skip_tables = TRUE )
2338 check_empty_tables(ts )
2439
40+ # TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
2541 expect_error(
2642 ts_load(ts_file , skip_reference_sequence = 1L ),
2743 regexp = " skip_reference_sequence must be TRUE/FALSE!"
2844 )
45+ expect_no_error(ts_ptr_load(ts_file , options = bitwShiftL(1L , 1L )))
2946 expect_no_error(ts_load(ts_file , skip_reference_sequence = TRUE ))
3047
31- expect_error(
32- ts_ptr_load(ts_file , options = bitwShiftL(1L , 30 )),
33- regexp = " ts_ptr_load only supports load options"
34- # TSK_LOAD_SKIP_TABLES (1 << 0) and TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
48+ ts_with_ref_seq_file <- system.file(
49+ " examples/test_with_ref_seq.trees" ,
50+ package = " RcppTskit"
3551 )
36-
52+ expect_no_error(ts_ptr_load(ts_with_ref_seq_file ))
53+ expect_no_error(ts_ptr_load(
54+ ts_with_ref_seq_file ,
55+ options = bitwShiftL(1L , 1L )
56+ ))
57+ expect_no_error(ts_load(ts_with_ref_seq_file ))
58+ expect_no_error(ts_load(ts_with_ref_seq_file , skip_reference_sequence = TRUE ))
59+
60+ # For tests below
3761 ts_ptr <- ts_ptr_load(ts_file )
3862 ts <- ts_load(ts_file )
3963
@@ -45,33 +69,57 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", {
4569 expect_error(tc_load(" nonexistent_ts" ))
4670 ts_file <- system.file(" examples/test.trees" , package = " RcppTskit" )
4771
72+ expect_error(
73+ tc_ptr_load(ts_file , options = bitwShiftL(1L , 30 )),
74+ regexp = " tc_ptr_load only supports load options"
75+ # TSK_LOAD_SKIP_TABLES (1 << 0) and TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
76+ )
77+
78+ # TSK_LOAD_SKIP_TABLES (1 << 0)
4879 expect_error(
4980 tc_load(ts_file , skip_tables = " y" ),
5081 regexp = " skip_tables must be TRUE/FALSE!"
5182 )
83+ expect_no_error(tc_ptr_load(ts_file , options = bitwShiftL(1L , 0L )))
5284 expect_no_error(tc_load(ts_file , skip_tables = TRUE ))
85+ check_empty_tables_ptr <- function (tc ) {
86+ # jarl-ignore implicit_assignment: it's just a test
87+ tmp <- capture.output(p <- tc_ptr_print(tc ))
88+ expect_true(all(p $ tables $ number == 0 ))
89+ }
5390 check_empty_tables <- function (tc ) {
54- # jarl-ignore implicit_assignment: it's just a test
91+ # jarl-ignore implicit_assignment: it's just a test
5592 tmp <- capture.output(p <- tc $ print())
5693 expect_true(all(p $ tables $ number == 0 ))
5794 }
95+ tc_ptr <- tc_ptr_load(ts_file , options = bitwShiftL(1L , 0L ))
96+ check_empty_tables_ptr(tc_ptr )
5897 tc <- tc_load(ts_file , skip_tables = TRUE )
5998 check_empty_tables(tc )
6099 tc <- TableCollection $ new(file = ts_file , skip_tables = TRUE )
61100 check_empty_tables(tc )
62101
102+ # TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
63103 expect_error(
64104 tc_load(ts_file , skip_reference_sequence = 1L ),
65105 regexp = " skip_reference_sequence must be TRUE/FALSE!"
66106 )
107+ expect_no_error(tc_ptr_load(ts_file , options = bitwShiftL(1L , 1L )))
67108 expect_no_error(tc_load(ts_file , skip_reference_sequence = TRUE ))
68109
69- expect_error(
70- tc_ptr_load(ts_file , options = bitwShiftL(1L , 30 )),
71- regexp = " tc_ptr_load only supports load options"
72- # TSK_LOAD_SKIP_TABLES (1 << 0) and TSK_LOAD_SKIP_REFERENCE_SEQUENCE (1 << 1)
110+ ts_with_ref_seq_file <- system.file(
111+ " examples/test_with_ref_seq.trees" ,
112+ package = " RcppTskit"
73113 )
74-
114+ expect_no_error(tc_ptr_load(ts_with_ref_seq_file ))
115+ expect_no_error(tc_ptr_load(
116+ ts_with_ref_seq_file ,
117+ options = bitwShiftL(1L , 1L )
118+ ))
119+ expect_no_error(tc_load(ts_with_ref_seq_file ))
120+ expect_no_error(tc_load(ts_with_ref_seq_file , skip_reference_sequence = TRUE ))
121+
122+ # For tests below
75123 tc_ptr <- tc_ptr_load(ts_file )
76124 tc <- tc_load(ts_file )
77125
0 commit comments