~tim/scheme-vm

172330ff87511cbcff43ba68c86f4c2a8dc422e8 — Tim Morgan 5 years ago cb7b8ec
Allow specifying debug output inside lib spec
1 files changed, 4 insertions(+), 3 deletions(-)

M spec/lib_spec.rb
M spec/lib_spec.rb => spec/lib_spec.rb +4 -3
@@ 10,15 10,16 @@ cached_program = Marshal.dump(program)
Dir[File.expand_path('../lib/**/*.scm', __FILE__)].each do |path|
  describe File.split(path).last do
    code = File.read(path).sub(/\(import \(scheme base\)\s+\(assert\)\s*\)/, '')
    focus = !(code =~ /^; focus/).nil?
    skip = !(code =~ /^; skip/).nil?
    focus = !(code =~ /^;; focus/).nil?
    skip = !(code =~ /^;; skip/).nil?
    debug = code =~ /^;; debug/ ? 2 : 0
    it 'passes all tests', focus: focus, skip: skip do
      failed = false
      out = DumpableStringIO.new
      program = Marshal.load(cached_program)
      program.filename = path
      program.stdout = out
      program.run(code: code)
      program.run(code: code, debug: debug)
      out.rewind
      result = out.read
      if result != ''