File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,12 @@ is_syntactic_literal <- function(x) {
133133 length(x ) == 1 && is.null(attributes(x )) && (is.na(x ) || x > = 0 )
134134 },
135135 complex = {
136- length(x ) == 1 && is.null(attributes(x )) && (is.na(x ) || (Re(x ) == 0 && Im(x ) > = 0 ))
136+ length(x ) == 1 &&
137+ is.null(attributes(x )) &&
138+ (
139+ (is.na(Re(x )) && is.na(Im(x ))) ||
140+ (! is.na(x ) && Re(x ) == 0 && Im(x ) > = 0 )
141+ )
137142 },
138143 FALSE
139144 )
Original file line number Diff line number Diff line change @@ -144,4 +144,10 @@ test_that("negative numbers are not syntactic", {
144144 expect_false(is_syntactic_literal(- 1 ))
145145 expect_false(is_syntactic_literal(- 1L ))
146146 expect_false(is_syntactic_literal(- 1i ))
147+ })
148+
149+ test_that(" NA + 1i is not syntactic" , {
150+ skip_if_not_installed(" base" , " 4.4" )
151+ expect_false(is_syntactic_literal(NA + 1i ))
152+ expect_false(is_syntactic_literal(NA - 1i ))
147153})
You can’t perform that action at this time.
0 commit comments