Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
d105ea49
Commit
d105ea49
authored
Jun 21, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #305 from bovi/optional-feature
Tests are executed based on available features
parents
0f2b6964
4780b653
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
323 additions
and
312 deletions
+323
-312
mrblib/struct.rb
mrblib/struct.rb
+41
-37
test/t/math.rb
test/t/math.rb
+90
-88
test/t/struct.rb
test/t/struct.rb
+52
-49
test/t/time.rb
test/t/time.rb
+140
-138
No files found.
mrblib/struct.rb
View file @
d105ea49
...
@@ -2,45 +2,49 @@
...
@@ -2,45 +2,49 @@
# Struct
# Struct
#
#
# ISO 15.2.18
# ISO 15.2.18
class
Struct
##
if
Object
.
const_defined?
(
:Struct
)
# Calls the given block for each element of +self+
class
Struct
# and pass the respective element.
#
# ISO 15.2.18.4.4
def
each
(
&
block
)
self
.
class
.
members
.
each
{
|
field
|
block
.
call
(
self
[
field
])
}
self
end
##
##
# Calls the given block for each element of +self+
# Calls the given block for each element of +self+
# and pass the name and value of the respectiev
# and pass the respective element.
# element.
#
#
# ISO 15.2.18.4.4
# ISO 15.2.18.4.5
def
each
(
&
block
)
def
each_pair
(
&
block
)
self
.
class
.
members
.
each
{
|
field
|
self
.
class
.
members
.
each
{
|
field
|
block
.
call
(
self
[
field
])
block
.
call
(
field
.
to_sym
,
self
[
field
])
}
}
self
self
end
end
##
##
# Calls the given block for each element of +self+
# Calls the given block for each element of +self+
# and returns an array with all elements of which
# and pass the name and value of the respectiev
# block is not false.
# element.
#
#
# ISO 15.2.18.4.7
# ISO 15.2.18.4.5
def
select
(
&
block
)
def
each_pair
(
&
block
)
ary
=
[]
self
.
class
.
members
.
each
{
|
field
|
self
.
class
.
members
.
each
{
|
field
|
block
.
call
(
field
.
to_sym
,
self
[
field
])
val
=
self
[
field
]
}
ary
.
push
(
val
)
if
block
.
call
(
val
)
self
}
end
ary
##
# Calls the given block for each element of +self+
# and returns an array with all elements of which
# block is not false.
#
# ISO 15.2.18.4.7
def
select
(
&
block
)
ary
=
[]
self
.
class
.
members
.
each
{
|
field
|
val
=
self
[
field
]
ary
.
push
(
val
)
if
block
.
call
(
val
)
}
ary
end
end
end
end
end
test/t/math.rb
View file @
d105ea49
##
##
# Math Test
# Math Test
assert
(
'Math.sin 0'
)
do
if
Object
.
const_defined?
(
:Math
)
check_float
(
Math
.
sin
(
0
),
0
)
assert
(
'Math.sin 0'
)
do
end
check_float
(
Math
.
sin
(
0
),
0
)
end
assert
(
'Math.sin PI/2'
)
do
assert
(
'Math.sin PI/2'
)
do
check_float
(
Math
.
sin
(
Math
::
PI
/
2
),
1
)
check_float
(
Math
.
sin
(
Math
::
PI
/
2
),
1
)
end
end
assert
(
'Fundamental trig identities'
)
do
result
=
true
N
=
15
N
.
times
do
|
i
|
a
=
Math
::
PI
/
N
*
i
ca
=
Math
::
PI
/
2
-
a
s
=
Math
.
sin
(
a
)
c
=
Math
.
cos
(
a
)
t
=
Math
.
tan
(
a
)
result
&=
check_float
(
s
,
Math
.
cos
(
ca
))
result
&=
check_float
(
t
,
1
/
Math
.
tan
(
ca
))
result
&=
check_float
(
s
**
2
+
c
**
2
,
1
)
result
&=
check_float
(
t
**
2
+
1
,
(
1
/
c
)
**
2
)
result
&=
check_float
((
1
/
t
)
**
2
+
1
,
(
1
/
s
)
**
2
)
end
result
end
assert
(
'Fundamental trig identities'
)
do
assert
(
'Math.erf 0'
)
do
result
=
true
check_float
(
Math
.
erf
(
0
),
0
)
N
=
15
end
N
.
times
do
|
i
|
a
=
Math
::
PI
/
N
*
i
ca
=
Math
::
PI
/
2
-
a
s
=
Math
.
sin
(
a
)
c
=
Math
.
cos
(
a
)
t
=
Math
.
tan
(
a
)
result
&=
check_float
(
s
,
Math
.
cos
(
ca
))
result
&=
check_float
(
t
,
1
/
Math
.
tan
(
ca
))
result
&=
check_float
(
s
**
2
+
c
**
2
,
1
)
result
&=
check_float
(
t
**
2
+
1
,
(
1
/
c
)
**
2
)
result
&=
check_float
((
1
/
t
)
**
2
+
1
,
(
1
/
s
)
**
2
)
end
result
end
assert
(
'Math.erf
0'
)
do
assert
(
'Math.exp
0'
)
do
check_float
(
Math
.
erf
(
0
),
0
)
check_float
(
Math
.
exp
(
0
),
1.
0
)
end
end
assert
(
'Math.exp 0
'
)
do
assert
(
'Math.exp 1
'
)
do
check_float
(
Math
.
exp
(
0
),
1.0
)
check_float
(
Math
.
exp
(
1
),
2.718281828459045
)
end
end
assert
(
'Math.exp 1
'
)
do
assert
(
'Math.exp 1.5
'
)
do
check_float
(
Math
.
exp
(
1
),
2.7182818284590
45
)
check_float
(
Math
.
exp
(
1.5
),
4.48168907033806
45
)
end
end
assert
(
'Math.exp 1.5
'
)
do
assert
(
'Math.log 1
'
)
do
check_float
(
Math
.
exp
(
1.5
),
4.4816890703380645
)
check_float
(
Math
.
log
(
1
),
0
)
end
end
assert
(
'Math.log 1
'
)
do
assert
(
'Math.log E
'
)
do
check_float
(
Math
.
log
(
1
),
0
)
check_float
(
Math
.
log
(
Math
::
E
),
1.
0
)
end
end
assert
(
'Math.log E
'
)
do
assert
(
'Math.log E**3
'
)
do
check_float
(
Math
.
log
(
Math
::
E
),
1
.0
)
check_float
(
Math
.
log
(
Math
::
E
**
3
),
3
.0
)
end
end
assert
(
'Math.log E**3
'
)
do
assert
(
'Math.log2 1
'
)
do
check_float
(
Math
.
log
(
Math
::
E
**
3
),
3
.0
)
check_float
(
Math
.
log2
(
1
),
0
.0
)
end
end
assert
(
'Math.log2 1
'
)
do
assert
(
'Math.log2 2
'
)
do
check_float
(
Math
.
log2
(
1
),
0
.0
)
check_float
(
Math
.
log2
(
2
),
1
.0
)
end
end
assert
(
'Math.log2 2
'
)
do
assert
(
'Math.log10 1
'
)
do
check_float
(
Math
.
log2
(
2
),
1
.0
)
check_float
(
Math
.
log10
(
1
),
0
.0
)
end
end
assert
(
'Math.log10 1
'
)
do
assert
(
'Math.log10 10
'
)
do
check_float
(
Math
.
log10
(
1
),
0
.0
)
check_float
(
Math
.
log10
(
10
),
1
.0
)
end
end
assert
(
'Math.log10 1
0'
)
do
assert
(
'Math.log10 10**10
0'
)
do
check_float
(
Math
.
log10
(
10
),
1
.0
)
check_float
(
Math
.
log10
(
10
**
100
),
100
.0
)
end
end
assert
(
'Math.log10 10**100'
)
do
assert
(
'Math.sqrt'
)
do
check_float
(
Math
.
log10
(
10
**
100
),
100.0
)
num
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
]
end
sqr
=
[
0
,
1
,
4
,
9
,
16
]
result
=
true
sqr
.
each_with_index
do
|
v
,
i
|
result
&=
check_float
(
Math
.
sqrt
(
v
),
num
[
i
])
end
result
end
assert
(
'Math.sqrt'
)
do
assert
(
'Math.cbrt'
)
do
num
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
]
num
=
[
-
2.0
,
-
1.0
,
0.0
,
1.0
,
2.0
]
sqr
=
[
0
,
1
,
4
,
9
,
16
]
cub
=
[
-
8
,
-
1
,
0
,
1
,
8
]
result
=
true
result
=
true
sqr
.
each_with_index
do
|
v
,
i
|
cub
.
each_with_index
do
|
v
,
i
|
result
&=
check_float
(
Math
.
sqrt
(
v
),
num
[
i
])
result
&=
check_float
(
Math
.
cbrt
(
v
),
num
[
i
])
end
result
end
end
result
end
assert
(
'Math.cbrt'
)
do
assert
(
'Math.hypot'
)
do
num
=
[
-
2.0
,
-
1.0
,
0.0
,
1.0
,
2.0
]
check_float
(
Math
.
hypot
(
3
,
4
),
5.0
)
cub
=
[
-
8
,
-
1
,
0
,
1
,
8
]
result
=
true
cub
.
each_with_index
do
|
v
,
i
|
result
&=
check_float
(
Math
.
cbrt
(
v
),
num
[
i
])
end
end
result
end
assert
(
'Math.hypot'
)
do
assert
(
'Math.frexp 1234'
)
do
check_float
(
Math
.
hypot
(
3
,
4
),
5.0
)
n
=
1234
end
fraction
,
exponent
=
Math
.
frexp
(
n
)
check_float
(
Math
.
ldexp
(
fraction
,
exponent
),
n
)
end
assert
(
'Math.frexp 1234'
)
do
assert
(
'Math.erf 1'
)
do
n
=
1234
check_float
(
Math
.
erf
(
1
),
0.842700792949715
)
fraction
,
exponent
=
Math
.
frexp
(
n
)
end
check_float
(
Math
.
ldexp
(
fraction
,
exponent
),
n
)
end
assert
(
'Math.erf 1'
)
do
assert
(
'Math.erfc 1'
)
do
check_float
(
Math
.
erf
(
1
),
0.842700792949715
)
check_float
(
Math
.
erfc
(
1
),
0.157299207050285
)
end
end
end
assert
(
'Math.erfc 1'
)
do
check_float
(
Math
.
erfc
(
1
),
0.157299207050285
)
end
test/t/struct.rb
View file @
d105ea49
##
##
# Struct ISO Test
# Struct ISO Test
assert
(
'Struct'
,
'15.2.18'
)
do
if
Object
.
const_defined?
(
:Struct
)
Struct
.
class
==
Class
assert
(
'Struct'
,
'15.2.18'
)
do
end
Struct
.
class
==
Class
end
assert
(
'Struct superclass'
,
'15.2.18.2'
)
do
assert
(
'Struct superclass'
,
'15.2.18.2'
)
do
Struct
.
superclass
==
Object
Struct
.
superclass
==
Object
end
end
assert
(
'Struct.new'
,
'15.2.18.3.1'
)
do
assert
(
'Struct.new'
,
'15.2.18.3.1'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
c
.
superclass
==
Struct
and
c
.
superclass
==
Struct
and
c
.
members
==
[
:m1
,
:m2
]
c
.
members
==
[
:m1
,
:m2
]
end
end
assert
(
'Struct#[]'
,
'15.2.18.4.2'
)
do
assert
(
'Struct#[]'
,
'15.2.18.4.2'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
cc
[
:m1
]
==
1
and
cc
[
"m2"
]
==
2
cc
[
:m1
]
==
1
and
cc
[
"m2"
]
==
2
end
end
assert
(
'Struct#[]='
,
'15.2.18.4.3'
)
do
assert
(
'Struct#[]='
,
'15.2.18.4.3'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
cc
[
:m1
]
=
3
cc
[
:m1
]
=
3
cc
[
:m1
]
==
3
cc
[
:m1
]
==
3
end
end
assert
(
'Struct#each'
,
'15.2.18.4.4'
)
do
assert
(
'Struct#each'
,
'15.2.18.4.4'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
a
=
[]
a
=
[]
cc
.
each
{
|
x
|
cc
.
each
{
|
x
|
a
<<
x
a
<<
x
}
}
a
[
0
]
==
1
and
a
[
1
]
==
2
a
[
0
]
==
1
and
a
[
1
]
==
2
end
end
assert
(
'Struct#each_pair'
,
'15.2.18.4.5'
)
do
assert
(
'Struct#each_pair'
,
'15.2.18.4.5'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
a
=
[]
a
=
[]
cc
.
each_pair
{
|
k
,
v
|
cc
.
each_pair
{
|
k
,
v
|
a
<<
[
k
,
v
]
a
<<
[
k
,
v
]
}
}
a
[
0
]
==
[
:m1
,
1
]
and
a
[
1
]
==
[
:m2
,
2
]
a
[
0
]
==
[
:m1
,
1
]
and
a
[
1
]
==
[
:m2
,
2
]
end
end
assert
(
'Struct#members'
,
'15.2.18.4.6'
)
do
assert
(
'Struct#members'
,
'15.2.18.4.6'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
cc
.
members
==
[
:m1
,
:m2
]
cc
.
members
==
[
:m1
,
:m2
]
end
end
assert
(
'Struct#select'
,
'15.2.18.4.7'
)
do
assert
(
'Struct#select'
,
'15.2.18.4.7'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
)
c
=
Struct
.
new
(
:m1
,
:m2
)
cc
=
c
.
new
(
1
,
2
)
cc
=
c
.
new
(
1
,
2
)
cc
.
select
{
|
v
|
v
%
2
==
0
}
==
[
2
]
cc
.
select
{
|
v
|
v
%
2
==
0
}
==
[
2
]
end
end
end
test/t/time.rb
View file @
d105ea49
##
##
# Time ISO Test
# Time ISO Test
assert
(
'Time.new'
,
'15.2.3.3.3'
)
do
if
Object
.
const_defined?
(
:Time
)
Time
.
new
.
class
==
Time
assert
(
'Time.new'
,
'15.2.3.3.3'
)
do
end
Time
.
new
.
class
==
Time
end
assert
(
'Time'
,
'15.2.19'
)
do
assert
(
'Time'
,
'15.2.19'
)
do
Time
.
class
==
Class
Time
.
class
==
Class
end
end
assert
(
'Time superclass'
,
'15.2.19.2'
)
do
assert
(
'Time superclass'
,
'15.2.19.2'
)
do
Time
.
superclass
==
Object
Time
.
superclass
==
Object
end
end
assert
(
'Time.at'
,
'15.2.19.6.1'
)
do
assert
(
'Time.at'
,
'15.2.19.6.1'
)
do
Time
.
at
(
1300000000.0
)
Time
.
at
(
1300000000.0
)
end
end
assert
(
'Time.gm'
,
'15.2.19.6.2'
)
do
assert
(
'Time.gm'
,
'15.2.19.6.2'
)
do
Time
.
gm
(
2012
,
12
,
23
)
Time
.
gm
(
2012
,
12
,
23
)
end
end
assert
(
'Time.local'
,
'15.2.19.6.3'
)
do
assert
(
'Time.local'
,
'15.2.19.6.3'
)
do
Time
.
local
(
2012
,
12
,
23
)
Time
.
local
(
2012
,
12
,
23
)
end
end
assert
(
'Time.mktime'
,
'15.2.19.6.4'
)
do
assert
(
'Time.mktime'
,
'15.2.19.6.4'
)
do
Time
.
mktime
(
2012
,
12
,
23
)
Time
.
mktime
(
2012
,
12
,
23
)
end
end
assert
(
'Time.now'
,
'15.2.19.6.5'
)
do
assert
(
'Time.now'
,
'15.2.19.6.5'
)
do
Time
.
now
.
class
==
Time
Time
.
now
.
class
==
Time
end
end
assert
(
'Time.utc'
,
'15.2.19.6.6'
)
do
assert
(
'Time.utc'
,
'15.2.19.6.6'
)
do
Time
.
utc
(
2012
,
12
,
23
)
Time
.
utc
(
2012
,
12
,
23
)
end
end
assert
(
'Time#+'
,
'15.2.19.7.1'
)
do
assert
(
'Time#+'
,
'15.2.19.7.1'
)
do
t1
=
Time
.
at
(
1300000000.0
)
t1
=
Time
.
at
(
1300000000.0
)
t2
=
t1
.
+
(
60
)
t2
=
t1
.
+
(
60
)
t2
.
utc
.
asctime
==
"Sun Mar 13 07:07:40 UTC 2011"
t2
.
utc
.
asctime
==
"Sun Mar 13 07:07:40 UTC 2011"
end
end
assert
(
'Time#-'
,
'15.2.19.7.2'
)
do
assert
(
'Time#-'
,
'15.2.19.7.2'
)
do
t1
=
Time
.
at
(
1300000000.0
)
t1
=
Time
.
at
(
1300000000.0
)
t2
=
t1
.
-
(
60
)
t2
=
t1
.
-
(
60
)
t2
.
utc
.
asctime
==
"Sun Mar 13 07:05:40 UTC 2011"
t2
.
utc
.
asctime
==
"Sun Mar 13 07:05:40 UTC 2011"
end
end
assert
(
'Time#<=>'
,
'15.2.19.7.3'
)
do
assert
(
'Time#<=>'
,
'15.2.19.7.3'
)
do
t1
=
Time
.
at
(
1300000000.0
)
t1
=
Time
.
at
(
1300000000.0
)
t2
=
Time
.
at
(
1400000000.0
)
t2
=
Time
.
at
(
1400000000.0
)
t3
=
Time
.
at
(
1500000000.0
)
t3
=
Time
.
at
(
1500000000.0
)
t2
.
<
=>
(
t1
)
==
1
and
t2
.
<
=>
(
t1
)
==
1
and
t2
.
<
=>
(
t2
)
==
0
and
t2
.
<
=>
(
t2
)
==
0
and
t2
.
<
=>
(
t3
)
==
-
1
and
t2
.
<
=>
(
t3
)
==
-
1
and
t2
.
<
=>
(
nil
)
==
nil
t2
.
<
=>
(
nil
)
==
nil
end
end
assert
(
'Time#asctime'
,
'15.2.19.7.4'
)
do
assert
(
'Time#asctime'
,
'15.2.19.7.4'
)
do
Time
.
at
(
1300000000.0
).
utc
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
Time
.
at
(
1300000000.0
).
utc
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
end
end
assert
(
'Time#ctime'
,
'15.2.19.7.5'
)
do
assert
(
'Time#ctime'
,
'15.2.19.7.5'
)
do
Time
.
at
(
1300000000.0
).
utc
.
ctime
==
"Sun Mar 13 07:06:40 UTC 2011"
Time
.
at
(
1300000000.0
).
utc
.
ctime
==
"Sun Mar 13 07:06:40 UTC 2011"
end
end
assert
(
'Time#day'
,
'15.2.19.7.6'
)
do
assert
(
'Time#day'
,
'15.2.19.7.6'
)
do
Time
.
gm
(
2012
,
12
,
23
).
day
==
23
Time
.
gm
(
2012
,
12
,
23
).
day
==
23
end
end
assert
(
'Time#dst?'
,
'15.2.19.7.7'
)
do
assert
(
'Time#dst?'
,
'15.2.19.7.7'
)
do
not
Time
.
gm
(
2012
,
12
,
23
).
utc
.
dst?
not
Time
.
gm
(
2012
,
12
,
23
).
utc
.
dst?
end
end
assert
(
'Time#getgm'
,
'15.2.19.7.8'
)
do
assert
(
'Time#getgm'
,
'15.2.19.7.8'
)
do
Time
.
at
(
1300000000.0
).
getgm
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
Time
.
at
(
1300000000.0
).
getgm
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
end
end
assert
(
'Time#getlocal'
,
'15.2.19.7.9'
)
do
assert
(
'Time#getlocal'
,
'15.2.19.7.9'
)
do
t1
=
Time
.
at
(
1300000000.0
)
t1
=
Time
.
at
(
1300000000.0
)
t2
=
Time
.
at
(
1300000000.0
)
t2
=
Time
.
at
(
1300000000.0
)
t3
=
t1
.
getlocal
t3
=
t1
.
getlocal
t1
==
t3
and
t3
==
t2
.
getlocal
t1
==
t3
and
t3
==
t2
.
getlocal
end
end
assert
(
'Time#getutc'
,
'15.2.19.7.10'
)
do
assert
(
'Time#getutc'
,
'15.2.19.7.10'
)
do
Time
.
at
(
1300000000.0
).
getutc
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
Time
.
at
(
1300000000.0
).
getutc
.
asctime
==
"Sun Mar 13 07:06:40 UTC 2011"
end
end
assert
(
'Time#gmt?'
,
'15.2.19.7.11'
)
do
assert
(
'Time#gmt?'
,
'15.2.19.7.11'
)
do
Time
.
at
(
1300000000.0
).
utc
.
gmt?
Time
.
at
(
1300000000.0
).
utc
.
gmt?
end
end
# ATM not implemented
# ATM not implemented
# assert('Time#gmt_offset', '15.2.19.7.12') do
# assert('Time#gmt_offset', '15.2.19.7.12') do
assert
(
'Time#gmtime'
,
'15.2.19.7.13'
)
do
assert
(
'Time#gmtime'
,
'15.2.19.7.13'
)
do
Time
.
at
(
1300000000.0
).
gmtime
Time
.
at
(
1300000000.0
).
gmtime
end
end
# ATM not implemented
# ATM not implemented
# assert('Time#gmtoff', '15.2.19.7.14') do
# assert('Time#gmtoff', '15.2.19.7.14') do
assert
(
'Time#hour'
,
'15.2.19.7.15'
)
do
assert
(
'Time#hour'
,
'15.2.19.7.15'
)
do
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
).
hour
==
7
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
).
hour
==
7
end
end
# ATM doesn't really work
# ATM doesn't really work
# assert('Time#initialize', '15.2.19.7.16') do
# assert('Time#initialize', '15.2.19.7.16') do
assert
(
'Time#initialize_copy'
,
'15.2.19.7.17'
)
do
assert
(
'Time#initialize_copy'
,
'15.2.19.7.17'
)
do
time_tmp_2
=
Time
.
at
(
7.0e6
)
time_tmp_2
=
Time
.
at
(
7.0e6
)
time_tmp_2
.
clone
==
time_tmp_2
time_tmp_2
.
clone
==
time_tmp_2
end
end
assert
(
'Time#localtime'
,
'15.2.19.7.18'
)
do
assert
(
'Time#localtime'
,
'15.2.19.7.18'
)
do
t1
=
Time
.
at
(
1300000000.0
)
t1
=
Time
.
at
(
1300000000.0
)
t2
=
Time
.
at
(
1300000000.0
)
t2
=
Time
.
at
(
1300000000.0
)
t1
.
localtime
t1
.
localtime
t1
==
t2
.
getlocal
t1
==
t2
.
getlocal
end
end
assert
(
'Time#mday'
,
'15.2.19.7.19'
)
do
assert
(
'Time#mday'
,
'15.2.19.7.19'
)
do
Time
.
gm
(
2012
,
12
,
23
).
mday
==
23
Time
.
gm
(
2012
,
12
,
23
).
mday
==
23
end
end
assert
(
'Time#min'
,
'15.2.19.7.20'
)
do
assert
(
'Time#min'
,
'15.2.19.7.20'
)
do
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
).
min
==
6
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
).
min
==
6
end
end
assert
(
'Time#mon'
,
'15.2.19.7.21'
)
do
assert
(
'Time#mon'
,
'15.2.19.7.21'
)
do
Time
.
gm
(
2012
,
12
,
23
).
mon
==
12
Time
.
gm
(
2012
,
12
,
23
).
mon
==
12
end
end
assert
(
'Time#month'
,
'15.2.19.7.22'
)
do
assert
(
'Time#month'
,
'15.2.19.7.22'
)
do
Time
.
gm
(
2012
,
12
,
23
).
month
==
12
Time
.
gm
(
2012
,
12
,
23
).
month
==
12
end
end
assert
(
'Times#sec'
,
'15.2.19.7.23'
)
do
assert
(
'Times#sec'
,
'15.2.19.7.23'
)
do
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
,
40
).
sec
==
40
Time
.
gm
(
2012
,
12
,
23
,
7
,
6
,
40
).
sec
==
40
end
end
assert
(
'Time#to_f'
,
'15.2.19.7.24'
)
do
assert
(
'Time#to_f'
,
'15.2.19.7.24'
)
do
Time
.
at
(
1300000000.0
).
to_f
==
1300000000.0
Time
.
at
(
1300000000.0
).
to_f
==
1300000000.0
end
end
assert
(
'Time#to_i'
,
'15.2.19.7.25'
)
do
assert
(
'Time#to_i'
,
'15.2.19.7.25'
)
do
Time
.
at
(
1300000000.0
).
to_i
==
1300000000
Time
.
at
(
1300000000.0
).
to_i
==
1300000000
end
end
assert
(
'Time#usec'
,
'15.2.19.7.26'
)
do
assert
(
'Time#usec'
,
'15.2.19.7.26'
)
do
Time
.
at
(
1300000000.0
).
usec
==
0
Time
.
at
(
1300000000.0
).
usec
==
0
end
end
assert
(
'Time#utc'
,
'15.2.19.7.27'
)
do
assert
(
'Time#utc'
,
'15.2.19.7.27'
)
do
Time
.
at
(
1300000000.0
).
utc
Time
.
at
(
1300000000.0
).
utc
end
end
assert
(
'Time#utc?'
,
'15.2.19.7.28'
)
do
assert
(
'Time#utc?'
,
'15.2.19.7.28'
)
do
Time
.
at
(
1300000000.0
).
utc
.
utc?
Time
.
at
(
1300000000.0
).
utc
.
utc?
end
end
# ATM not implemented
# ATM not implemented
# assert('Time#utc_offset', '15.2.19.7.29') do
# assert('Time#utc_offset', '15.2.19.7.29') do
assert
(
'Time#wday'
,
'15.2.19.7.30'
)
do
assert
(
'Time#wday'
,
'15.2.19.7.30'
)
do
Time
.
gm
(
2012
,
12
,
23
).
wday
==
0
Time
.
gm
(
2012
,
12
,
23
).
wday
==
0
end
end
assert
(
'Time#yday'
,
'15.2.19.7.31'
)
do
assert
(
'Time#yday'
,
'15.2.19.7.31'
)
do
Time
.
gm
(
2012
,
12
,
23
).
yday
==
357
Time
.
gm
(
2012
,
12
,
23
).
yday
==
357
end
end
assert
(
'Time#year'
,
'15.2.19.7.32'
)
do
assert
(
'Time#year'
,
'15.2.19.7.32'
)
do
Time
.
gm
(
2012
,
12
,
23
).
year
==
2012
Time
.
gm
(
2012
,
12
,
23
).
year
==
2012
end
end
assert
(
'Time#zone'
,
'15.2.19.7.33'
)
do
assert
(
'Time#zone'
,
'15.2.19.7.33'
)
do
Time
.
at
(
1300000000.0
).
utc
.
zone
==
'UTC'
Time
.
at
(
1300000000.0
).
utc
.
zone
==
'UTC'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment