rpl.rb/spec/language_time-date_spec.rb
2022-02-09 13:38:32 +01:00

35 lines
754 B
Ruby

# coding: utf-8
# frozen_string_literal: true
require 'test/unit'
require_relative '../interpreter'
class TestLanguageTimeDate < Test::Unit::TestCase
def test_time
now = Time.now.to_s
interpreter = Rpl::Interpreter.new
interpreter.run 'time'
assert_equal [{ value: now, type: :string }],
interpreter.stack
end
def test_date
now = Date.today.to_s
interpreter = Rpl::Interpreter.new
interpreter.run 'date'
assert_equal [{ value: now, type: :string }],
interpreter.stack
end
def test_ticks
interpreter = Rpl::Interpreter.new
interpreter.run 'ticks'
# TODO: better test, but how?
assert_equal :numeric,
interpreter.stack[0][:type]
end
end