2021-11-23 21:03:17 +01:00
|
|
|
# coding: utf-8
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'test/unit'
|
|
|
|
|
|
|
|
require_relative '../lib/core'
|
|
|
|
|
|
|
|
class TestParser < Test::Unit::TestCase
|
|
|
|
def test_stack_extract
|
2021-12-07 15:50:58 +01:00
|
|
|
stack, args = Rpl::Lang::Core.stack_extract [{ value: 1, type: :numeric },
|
|
|
|
{ value: 2, type: :numeric }],
|
|
|
|
[:any]
|
2021-11-23 21:03:17 +01:00
|
|
|
assert_equal [{ value: 1, type: :numeric }],
|
|
|
|
stack
|
|
|
|
assert_equal [{ value: 2, type: :numeric }],
|
|
|
|
args
|
|
|
|
|
2021-12-07 15:50:58 +01:00
|
|
|
stack, args = Rpl::Lang::Core.stack_extract [{ value: 'test', type: :string },
|
|
|
|
{ value: 2, type: :numeric }],
|
|
|
|
[[:numeric], :any]
|
2021-11-23 21:03:17 +01:00
|
|
|
assert_equal [],
|
|
|
|
stack
|
2021-11-24 13:52:32 +01:00
|
|
|
assert_equal [{ value: 2, type: :numeric },
|
2021-11-24 13:53:41 +01:00
|
|
|
{ value: 'test', type: :string }],
|
2021-11-23 21:03:17 +01:00
|
|
|
args
|
|
|
|
end
|
|
|
|
end
|