2021-11-18 15:44:09 +01:00
|
|
|
# coding: utf-8
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'test/unit'
|
|
|
|
|
2021-12-07 16:46:33 +01:00
|
|
|
require_relative '../language'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2021-11-23 13:00:42 +01:00
|
|
|
class TestLanguageTimeDate < Test::Unit::TestCase
|
2021-11-18 15:44:09 +01:00
|
|
|
def test_time
|
|
|
|
now = Time.now.to_s
|
2021-12-08 16:08:49 +01:00
|
|
|
lang = Rpl::Language.new
|
|
|
|
lang.run 'time'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-01-26 18:30:51 +01:00
|
|
|
assert_equal [{ value: now, type: :string }],
|
2021-12-08 16:08:49 +01:00
|
|
|
lang.stack
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_date
|
|
|
|
now = Date.today.to_s
|
2021-12-08 16:08:49 +01:00
|
|
|
lang = Rpl::Language.new
|
|
|
|
lang.run 'date'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-01-26 18:30:51 +01:00
|
|
|
assert_equal [{ value: now, type: :string }],
|
2021-12-08 16:08:49 +01:00
|
|
|
lang.stack
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ticks
|
2021-12-08 16:08:49 +01:00
|
|
|
lang = Rpl::Language.new
|
|
|
|
lang.run 'ticks'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
|
|
|
# TODO: better test, but how?
|
|
|
|
assert_equal :numeric,
|
2021-12-08 16:08:49 +01:00
|
|
|
lang.stack[0][:type]
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
end
|