File: deparse.R

package info (click to toggle)
r-cran-r.rsp 0.45.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,568 kB
  • sloc: javascript: 612; tcl: 304; sh: 18; makefile: 16
file content (32 lines) | stat: -rw-r--r-- 945 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library("R.rsp")
Arguments <- R.utils::Arguments
enter <- R.utils::enter
exit <- R.utils::exit

verbose <- Arguments$getVerbose(TRUE)

path <- system.file(package="R.rsp")
path <- file.path(path, "rsp_tests")

pathname <- file.path(path, "trimming-1.txt.rsp")

verbose && enter(verbose, "Validating that the RSP parse output can be deparsed")

untils <- rev(eval(formals(R.rsp:::parseDocument.RspParser)$until))
untils <- setdiff(untils, "*")

for (kk in seq_along(untils)) {
  until <- untils[kk]
  verbose && enter(verbose, sprintf("Until #%d ('%s') of %d", kk, until, length(untils)))
  s0 <- rcompile(file=pathname, until=until, output=RspString())
  d0 <- parseDocument(s0, until=until)
  stopifnot(inherits(d0, "RspDocument"))
  s1 <- asRspString(d0)
  d1 <- parseDocument(s1, until=until)
  stopifnot(inherits(d1, "RspDocument"))
  stopifnot(identical(d1, d0))
  stopifnot(s1 == s0)
  verbose && exit(verbose)
}

verbose && exit(verbose)