@@ -77,43 +77,20 @@ expect_snapshot_value <- function(
7777# Safe environment for evaluating deparsed objects, based on inspection of
7878# https://github.com/wch/r-source/blob/5234fe7b40aad8d3929d240c83203fa97d8c79fc/src/main/deparse.c#L845
7979reparse <- function (x ) {
80- env <- env(
81- emptyenv(),
82- `-` = `-` ,
83- c = c ,
84- list = list ,
85- quote = quote ,
86- structure = structure ,
87- expression = expression ,
88- `function` = `function` ,
89- new = methods :: new ,
90- getClass = methods :: getClass ,
91- pairlist = pairlist ,
92- alist = alist ,
93- as.pairlist = as.pairlist
94- )
95-
96- eval(parse(text = x ), env )
97- }
98-
99- # Safe environment for evaluating deparsed objects, based on inspection of
100- # https://github.com/wch/r-source/blob/5234fe7b40aad8d3929d240c83203fa97d8c79fc/src/main/deparse.c#L845
101- reparse <- function (x ) {
102- env <- env(
103- emptyenv(),
104- `-` = `-` ,
105- c = c ,
106- list = list ,
107- quote = quote ,
108- structure = structure ,
109- expression = expression ,
110- `function` = `function` ,
111- new = methods :: new ,
112- getClass = methods :: getClass ,
113- pairlist = pairlist ,
114- alist = alist ,
115- as.pairlist = as.pairlist
80+ env <- env(emptyenv())
81+ env_bind(
82+ env ,
83+ !!! env_get_list(
84+ base_env(),
85+ c(
86+ c(" c" , " structure" , " :" , " -" ),
87+ c(" list" , " numeric" , " integer" , " logical" , " character" ),
88+ " function" ,
89+ c(" quote" , " alist" , " pairlist" , " as.pairlist" , " expression" )
90+ )
91+ )
11692 )
93+ env_bind(env , !!! env_get_list(ns_env(" methods" ), c(" new" , " getClass" )))
11794
11895 eval(parse(text = x ), env )
11996}
0 commit comments