Sha256: 6f95c40c69f21fd96c8a572f6ae7ec96a4e329d62062ea3f6be676df2a0c32ff

Contents?: true

Size: 582 Bytes

Versions: 6

Compression:

Stored size: 582 Bytes

Contents

require 'helper'

class TestVM < Test::Unit::TestCase
  
  PROGRAMS = File.readlines(File.join(File.dirname(__FILE__), "test_vm_programs.txt"))
  RESULTS = File.readlines(File.join(File.dirname(__FILE__), "test_vm_results.txt"))
  
  context "The VM" do
    setup do
      @parser = PLangParser.new
    end

    PROGRAMS.each_with_index do |program, i|
      should "interp the program ##{i}" do
        ast = @parser.parse(program)
        vm = PLang::VM.new(ast.build.collect(&:to_sexp))
        assert_equal eval(RESULTS[i]), vm.execute!.params[0]
      end
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
p-lang-0.1.1 test/test_vm.rb
p-lang-0.1.0 test/test_vm.rb
p-lang-0.0.4 test/test_vm.rb
p-lang-0.0.3 test/test_vm.rb
p-lang-0.0.2 test/test_vm.rb
p-lang-0.0.1 test/test_vm.rb