Hi,
I am looking for the equivalent of capture.output for stdin. Imagine I am
writing a test for a function that reads from stdin, say scan.

>1: foobar
2: Read 1 item
[1] "foobar"

(please don't reply that scan can also read from a file, that's not what I
am trying to test; let's say I found a bug that occurs only when reading
from stdin, fixed it and I want to add a test specifically for that case; in
reality I am dealing with a function that only reads from stdin)
Looking good, but we need to automate that. So what I would like to write is
an assertion such as

"foobar" == feed.input("foobar", scan, what = "character")

feed.input would evaluate scan(what="character") while redirecting stdin so
that it consists of the characters "foobar" followed by EOF.

I googled this to exhaustion, but couldn't find a solution. I also looked at
testing frameworks, while I am not familiar with any of them, I didn't see
anything obviously related to this problem. Any suggestions? Thanks


Antonio

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to