-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtime_spec.rb
More file actions
88 lines (73 loc) · 1.84 KB
/
time_spec.rb
File metadata and controls
88 lines (73 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require "time"
require "mruby_engine"
require "spec_helper"
describe "Time" do
include EngineSpecHelper
let(:engine) { make_test_engine }
def eval_test(source)
engine.sandbox_eval("test.rb", source)
end
it "test the functionality of time" do
test = Pathname.new(__FILE__).dirname.join("mruby_time.mrb")
engine.sandbox_eval("mruby_time.rb", File.read(test))
end
describe "#new" do
it "returns a fixed moment in time" do
eval_test(<<-SOURCE)
assert_equal(Time.new(1970, 1, 1, 0, 0, 0, 0), Time.new)
SOURCE
end
end
it "does not respond to Time.now" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :now)
SOURCE
end
it "does not respond to Time.local" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :local)
SOURCE
end
it "does not respond to Time.localtime" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :localtime)
SOURCE
end
it "does not respond to Time.mktime" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :mktime)
SOURCE
end
it "does not respond to Time.gmt?" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :gmt?)
SOURCE
end
it "does not respond to Time.getgm" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :getgm)
SOURCE
end
it "does not respond to Time.gmtime" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :gmtime)
SOURCE
end
it "does not respond to Time.gm" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :gm)
SOURCE
end
it "does not respond to Time.gm" do
eval_test(<<-SOURCE)
refute_respond_to(Time, :getlocal)
SOURCE
end
it "raises if time is out of range" do
eval_test(<<-SOURCE)
assert_raises(ArgumentError, "9.367487224930632e+17 out of Time range") do
Time.at(0xd00000000000000)
end
SOURCE
end
end