nlfiedler / bakeneko

Scheme R7RS interpreter in Go
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Testing output in interpreter unit tests #28

Open nlfiedler opened 11 years ago

nlfiedler commented 11 years ago

For testing the results of evaluation, can assign "stdout" in the global environment to a bytes.Buffer then read the contents of that to see what the s-expr yielded.

nlfiedler commented 10 years ago

Scheme provides several procedures that would make this easily testable. Starting with (get-output-string) which retrieves the contents of the port created with (open-output-string), and (parameterize) which is used to temporarily change the definition of (current-output-port). See the R7RS for an example using (get-output-string).