2021-11-18 15:44:09 +01:00
|
|
|
# coding: utf-8
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-17 15:09:29 +01:00
|
|
|
require 'minitest/autorun'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-02-15 17:06:19 +01:00
|
|
|
require 'rpl'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-02-17 15:09:29 +01:00
|
|
|
class TestLanguageTimeDate < MiniTest::Test
|
2022-02-26 18:53:39 +01:00
|
|
|
include Types
|
|
|
|
|
2021-11-18 15:44:09 +01:00
|
|
|
def test_time
|
2022-03-09 13:20:34 +01:00
|
|
|
now = Time.now.to_s.split[1]
|
2022-02-10 14:50:59 +01:00
|
|
|
interpreter = Rpl.new
|
2022-02-09 13:38:32 +01:00
|
|
|
interpreter.run 'time'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-02-28 11:40:47 +01:00
|
|
|
assert_equal [Types.new_object( RplString, "\"#{now}\"" )],
|
2022-02-09 13:38:32 +01:00
|
|
|
interpreter.stack
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_date
|
|
|
|
now = Date.today.to_s
|
2022-02-10 14:50:59 +01:00
|
|
|
interpreter = Rpl.new
|
2022-02-09 13:38:32 +01:00
|
|
|
interpreter.run 'date'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
2022-02-28 11:40:47 +01:00
|
|
|
assert_equal [Types.new_object( RplString, "\"#{now}\"" )],
|
2022-02-09 13:38:32 +01:00
|
|
|
interpreter.stack
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ticks
|
2022-02-10 14:50:59 +01:00
|
|
|
interpreter = Rpl.new
|
2022-02-09 13:38:32 +01:00
|
|
|
interpreter.run 'ticks'
|
2021-11-18 15:44:09 +01:00
|
|
|
|
|
|
|
# TODO: better test, but how?
|
2022-02-26 18:53:39 +01:00
|
|
|
assert_equal RplNumeric,
|
|
|
|
interpreter.stack[0].class
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
end
|