test/test_vm.rb in p-lang-0.1.1 vs test/test_vm.rb in p-lang-0.2.0

- old
+ new

@@ -1,22 +1,19 @@ 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")) + PROGRAMS = File.readlines(File.join(File.dirname(__FILE__), "test_vm")) + RESULT = File.readlines(File.join(File.dirname(__FILE__), "test_vm_result")) 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] + vm = PLang::VM::Interpreter.new(PLang::Parser::SyntaxAnalyser.new(program).parse) + should "interp the expression ##{i}" do + assert_equal vm.execute!.params[0], eval(RESULT[i]) end end + end end