rpl.rb/spec/language_program_spec.rb

30 lines
1.1 KiB
Ruby
Raw Normal View History

2021-11-18 12:00:02 +01:00
# frozen_string_literal: true
require 'test/unit'
require_relative '../language'
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
stack, _dictionary = Rpl::Lang::Core.eval( [{ value: '« 2 dup * dup »', type: :program }], Rpl::Lang::Dictionary.new )
2021-11-18 12:11:19 +01:00
assert_equal [{ value: 4, type: :numeric, base: 10 },
{ value: 4, type: :numeric, base: 10 }],
2021-11-18 12:00:02 +01:00
stack
2021-11-18 14:23:56 +01:00
stack, _dictionary = Rpl::Lang::Core.eval( [{ value: 4, type: :numeric, base: 10 },
{ value: "'dup'", type: :name }], Rpl::Lang::Dictionary.new )
2021-11-18 14:23:56 +01:00
assert_equal [{ value: 4, type: :numeric, base: 10 },
{ value: 4, type: :numeric, base: 10 }],
2021-11-18 14:23:56 +01:00
stack
stack, _dictionary = Rpl::Lang::Core.eval( [{ value: 4, type: :numeric, base: 10 },
{ value: 'dup', type: :word }], Rpl::Lang::Dictionary.new )
2021-11-18 14:23:56 +01:00
assert_equal [{ value: 4, type: :numeric, base: 10 },
{ value: 4, type: :numeric, base: 10 }],
2021-11-18 14:23:56 +01:00
stack
2021-11-18 12:00:02 +01:00
end
end