@@ -50,55 +50,22 @@ patrick::with_parameters_test_that(
5050 literal_coercion_linter()
5151 ),
5252 .cases = tibble :: tribble(
53- ~ .test_name ,
54- ~ out_type ,
55- ~ input ,
56- ~ lint_msg ,
57- " lgl, from int" ,
58- " logical" ,
59- " 1L" ,
60- " Use TRUE instead of as.logical(1L)" ,
61- " lgl, from num" ,
62- " logical" ,
63- " 1" ,
64- " Use TRUE instead of as.logical(1)" ,
65- " lgl, from chr" ,
66- " logical" ,
67- ' "true"' ,
68- ' Use TRUE instead of as.logical("true")' ,
69- " int, from num" ,
70- " integer" ,
71- " 1" ,
72- " Use 1L instead of as.integer(1)" ,
73- " num, from num" ,
74- " numeric" ,
75- " 1" ,
76- " Use 1 instead of as.numeric(1)" ,
77- " dbl, from num" ,
78- " double" ,
79- " 1" ,
80- " Use 1 instead of as.double(1)" ,
81- # "chr, from num", "character", "1", 'Use "1" instead of as.character(1)',
82- # "chr, from chr", "character", '"e"', 'Use "e" instead of as.character("e")',
83- # "chr, from chr", "character", '"E"', 'Use "E" instead of as.character("E")',
84- # affirmatively lint as.<type>(NA) should be NA_<type>_
85- " int, from NA" ,
86- " integer" ,
87- " NA" ,
88- " Use NA_integer_ instead of as.integer(NA)" ,
89- " num, from NA" ,
90- " numeric" ,
91- " NA" ,
92- " Use NA_real_ instead of as.numeric(NA)" ,
93- " dbl, from NA" ,
94- " double" ,
95- " NA" ,
96- " Use NA_real_ instead of as.double(NA)" ,
97- " chr, from NA" ,
98- " character" ,
99- " NA" ,
100- " Use NA_character_ instead of as.character(NA)"
53+ ~ .test_name , ~ out_type , ~ input , ~ lint_msg ,
54+ " lgl, from int" , " logical" , " 1L" , " Use TRUE instead of as.logical(1L)" ,
55+ " lgl, from num" , " logical" , " 1" , " Use TRUE instead of as.logical(1)" ,
56+ " lgl, from chr" , " logical" , " \" true\" " , " Use TRUE instead of as.logical(\" true\" )" ,
57+ " int, from num" , " integer" , " 1" , " Use 1L instead of as.integer(1)" ,
58+ " num, from num" , " numeric" , " 1" , " Use 1 instead of as.numeric(1)" ,
59+ " dbl, from num" , " double" , " 1" , " Use 1 instead of as.double(1)" ,
60+ " int, from NA" , " integer" , NA , " Use NA_integer_ instead of as.integer(NA)" ,
61+ " num, from NA" , " numeric" , NA , " Use NA_real_ instead of as.numeric(NA)" ,
62+ " dbl, from NA" , " double" , NA , " Use NA_real_ instead of as.double(NA)" ,
63+ " chr, from NA" , " character" , NA , " Use NA_character_ instead of as.character(NA)"
10164 )
65+ # "chr, from num", "character", "1", 'Use "1" instead of as.character(1)',
66+ # "chr, from chr", "character", '"e"', 'Use "e" instead of as.character("e")',
67+ # "chr, from chr", "character", '"E"', 'Use "E" instead of as.character("E")',
68+ # affirmatively lint as.<type>(NA) should be NA_<type>_
10269)
10370
10471# TODO
@@ -125,53 +92,53 @@ patrick::with_parameters_test_that(
12592 " literal_coercion_linter blocks simple disallowed usages" ,
12693 expect_snapshot(fix_text(sprintf(" as.%s(%s)" , out_type , input ))),
12794 .cases = tibble :: tribble(
128- ~ .test_name ,
129- ~ out_type ,
130- ~ input ,
131- ~ lint_msg ,
132- " lgl, from int" ,
133- " logical" ,
134- " 1L" ,
135- " Use TRUE instead of as.logical(1L)" ,
136- " lgl, from num" ,
137- " logical" ,
138- " 1" ,
139- " Use TRUE instead of as.logical(1)" ,
140- " lgl, from chr" ,
141- " logical" ,
142- ' "true"' ,
143- ' Use TRUE instead of as.logical("true")' ,
144- " int, from num" ,
145- " integer" ,
146- " 1" ,
147- " Use 1L instead of as.integer(1)" ,
148- " num, from num" ,
149- " numeric" ,
150- " 1" ,
151- " Use 1 instead of as.numeric(1)" ,
152- " dbl, from num" ,
153- " double" ,
154- " 1" ,
155- " Use 1 instead of as.double(1)" ,
95+ ~ .test_name ,
96+ ~ out_type ,
97+ ~ input ,
98+ ~ lint_msg ,
99+ " lgl, from int" ,
100+ " logical" ,
101+ " 1L" ,
102+ " Use TRUE instead of as.logical(1L)" ,
103+ " lgl, from num" ,
104+ " logical" ,
105+ " 1" ,
106+ " Use TRUE instead of as.logical(1)" ,
107+ " lgl, from chr" ,
108+ " logical" ,
109+ ' "true"' ,
110+ ' Use TRUE instead of as.logical("true")' ,
111+ " int, from num" ,
112+ " integer" ,
113+ " 1" ,
114+ " Use 1L instead of as.integer(1)" ,
115+ " num, from num" ,
116+ " numeric" ,
117+ " 1" ,
118+ " Use 1 instead of as.numeric(1)" ,
119+ " dbl, from num" ,
120+ " double" ,
121+ " 1" ,
122+ " Use 1 instead of as.double(1)" ,
156123 # "chr, from num", "character", "1", 'Use "1" instead of as.character(1)',
157124 # "chr, from chr", "character", '"e"', 'Use "e" instead of as.character("e")',
158125 # "chr, from chr", "character", '"E"', 'Use "E" instead of as.character("E")',
159126 # affirmatively lint as.<type>(NA) should be NA_<type>_
160- " int, from NA" ,
161- " integer" ,
162- " NA" ,
163- " Use NA_integer_ instead of as.integer(NA)" ,
164- " num, from NA" ,
165- " numeric" ,
166- " NA" ,
167- " Use NA_real_ instead of as.numeric(NA)" ,
168- " dbl, from NA" ,
169- " double" ,
170- " NA" ,
171- " Use NA_real_ instead of as.double(NA)" ,
172- " chr, from NA" ,
173- " character" ,
174- " NA" ,
127+ " int, from NA" ,
128+ " integer" ,
129+ " NA" ,
130+ " Use NA_integer_ instead of as.integer(NA)" ,
131+ " num, from NA" ,
132+ " numeric" ,
133+ " NA" ,
134+ " Use NA_real_ instead of as.numeric(NA)" ,
135+ " dbl, from NA" ,
136+ " double" ,
137+ " NA" ,
138+ " Use NA_real_ instead of as.double(NA)" ,
139+ " chr, from NA" ,
140+ " character" ,
141+ " NA" ,
175142 " Use NA_character_ instead of as.character(NA)"
176143 )
177144)
0 commit comments