rpl.rb/spec/language_program_spec.rb

24 lines
629 B
Ruby
Raw Normal View History

2021-11-18 12:00:02 +01:00
# frozen_string_literal: true
require 'test/unit'
require_relative '../interpreter'
2021-11-18 12:00:02 +01:00
2021-11-23 13:00:42 +01:00
class TestLanguageProgram < Test::Unit::TestCase
2021-11-18 12:00:02 +01:00
def test_eval
interpreter = Rpl::Interpreter.new
interpreter.run '« 2 dup * dup » eval'
2021-11-18 12:11:19 +01:00
assert_equal [{ value: 4, type: :numeric, base: 10 },
{ value: 4, type: :numeric, base: 10 }],
interpreter.stack
2021-11-18 14:23:56 +01:00
interpreter = Rpl::Interpreter.new
interpreter.run '4 \'dup\' eval'
2021-11-18 14:23:56 +01:00
assert_equal [{ value: 4, type: :numeric, base: 10 },
{ value: 4, type: :numeric, base: 10 }],
interpreter.stack
2021-11-18 12:00:02 +01:00
end
end