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
97600ded
Commit
97600ded
authored
May 20, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the order of "expected" and "actual" in `mruby-rational` test
parent
8b8bf9f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
+34
-34
mrbgems/mruby-rational/test/rational.rb
mrbgems/mruby-rational/test/rational.rb
+34
-34
No files found.
mrbgems/mruby-rational/test/rational.rb
View file @
97600ded
def
assert_rational
(
real
,
exp
)
assert_float
real
.
numerator
,
exp
.
numerator
assert_float
real
.
denominator
,
exp
.
denominator
def
assert_rational
(
exp
,
real
)
assert_float
exp
.
numerator
,
real
.
numerator
assert_float
exp
.
denominator
,
real
.
denominator
end
def
assert_equal_rational
(
exp
,
o1
,
o2
)
...
...
@@ -23,55 +23,55 @@ end
assert
'Rational'
do
r
=
5
r
assert_equal
Rational
,
r
.
class
assert_equal
[
r
.
numerator
,
r
.
denominator
],
[
5
,
1
]
assert_equal
(
r
.
class
,
Rational
)
assert_equal
([
5
,
1
],
[
r
.
numerator
,
r
.
denominator
])
end
assert
'Rational#to_f'
do
assert_float
Rational
(
2
).
to_f
,
2.0
assert_float
Rational
(
9
,
4
).
to_f
,
2.25
assert_float
Rational
(
-
3
,
4
).
to_f
,
-
0.75
assert_float
Rational
(
20
,
3
).
to_f
,
6.666666666666667
assert_float
(
2.0
,
Rational
(
2
).
to_f
)
assert_float
(
2.25
,
Rational
(
9
,
4
).
to_f
)
assert_float
(
-
0.75
,
Rational
(
-
3
,
4
).
to_f
)
assert_float
(
6.666666666666667
,
Rational
(
20
,
3
).
to_f
)
end
assert
'Rational#to_i'
do
assert_equal
Rational
(
2
,
3
).
to_i
,
0
assert_equal
Rational
(
3
).
to_i
,
3
assert_equal
Rational
(
300.6
).
to_i
,
300
assert_equal
Rational
(
98
,
71
).
to_i
,
1
assert_equal
Rational
(
-
30
,
2
).
to_i
,
-
15
assert_equal
(
0
,
Rational
(
2
,
3
).
to_i
)
assert_equal
(
3
,
Rational
(
3
).
to_i
)
assert_equal
(
300
,
Rational
(
300.6
).
to_i
)
assert_equal
(
1
,
Rational
(
98
,
71
).
to_i
)
assert_equal
(
-
15
,
Rational
(
-
30
,
2
).
to_i
)
end
assert
'Rational#*'
do
assert_rational
Rational
(
2
,
3
)
*
Rational
(
2
,
3
),
Rational
(
4
,
9
)
assert_rational
Rational
(
900
)
*
Rational
(
1
),
Rational
(
900
,
1
)
assert_rational
Rational
(
-
2
,
9
)
*
Rational
(
-
9
,
2
),
Rational
(
1
,
1
)
assert_rational
Rational
(
9
,
8
)
*
4
,
Rational
(
9
,
2
)
assert_float
Rational
(
20
,
9
)
*
9.8
,
21.77777777777778
assert_rational
(
Rational
(
4
,
9
),
Rational
(
2
,
3
)
*
Rational
(
2
,
3
)
)
assert_rational
(
Rational
(
900
,
1
),
Rational
(
900
)
*
Rational
(
1
)
)
assert_rational
(
Rational
(
1
,
1
),
Rational
(
-
2
,
9
)
*
Rational
(
-
9
,
2
)
)
assert_rational
(
Rational
(
9
,
2
),
Rational
(
9
,
8
)
*
4
)
assert_float
(
21.77777777777778
,
Rational
(
20
,
9
)
*
9.8
)
end
assert
'Rational#+'
do
assert_rational
Rational
(
2
,
3
)
+
Rational
(
2
,
3
),
Rational
(
4
,
3
)
assert_rational
Rational
(
900
)
+
Rational
(
1
),
Rational
(
901
,
1
)
assert_rational
Rational
(
-
2
,
9
)
+
Rational
(
-
9
,
2
),
Rational
(
-
85
,
18
)
assert_rational
Rational
(
9
,
8
)
+
4
,
Rational
(
41
,
8
)
assert_float
Rational
(
20
,
9
)
+
9.8
,
12.022222222222222
assert_rational
(
Rational
(
4
,
3
),
Rational
(
2
,
3
)
+
Rational
(
2
,
3
)
)
assert_rational
(
Rational
(
901
,
1
),
Rational
(
900
)
+
Rational
(
1
)
)
assert_rational
(
Rational
(
-
85
,
18
),
Rational
(
-
2
,
9
)
+
Rational
(
-
9
,
2
)
)
assert_rational
(
Rational
(
41
,
8
),
Rational
(
9
,
8
)
+
4
)
assert_float
(
12.022222222222222
,
Rational
(
20
,
9
)
+
9.8
)
end
assert
'Rational#-'
do
assert_rational
Rational
(
2
,
3
)
-
Rational
(
2
,
3
),
Rational
(
0
,
1
)
assert_rational
Rational
(
900
)
-
Rational
(
1
),
Rational
(
899
,
1
)
assert_rational
Rational
(
-
2
,
9
)
-
Rational
(
-
9
,
2
),
Rational
(
77
,
18
)
assert_rational
Rational
(
9
,
8
)
-
4
,
Rational
(
-
23
,
8
)
assert_float
Rational
(
20
,
9
)
-
9.8
,
-
7.577777777777778
assert_rational
(
Rational
(
0
,
1
),
Rational
(
2
,
3
)
-
Rational
(
2
,
3
)
)
assert_rational
(
Rational
(
899
,
1
),
Rational
(
900
)
-
Rational
(
1
)
)
assert_rational
(
Rational
(
77
,
18
),
Rational
(
-
2
,
9
)
-
Rational
(
-
9
,
2
)
)
assert_rational
(
Rational
(
-
23
,
8
),
Rational
(
9
,
8
)
-
4
)
assert_float
(
-
7.577777777777778
,
Rational
(
20
,
9
)
-
9.8
)
end
assert
'Rational#/'
do
assert_rational
Rational
(
2
,
3
)
/
Rational
(
2
,
3
),
Rational
(
1
,
1
)
assert_rational
Rational
(
900
)
/
Rational
(
1
),
Rational
(
900
,
1
)
assert_rational
Rational
(
-
2
,
9
)
/
Rational
(
-
9
,
2
),
Rational
(
4
,
81
)
assert_rational
Rational
(
9
,
8
)
/
4
,
Rational
(
9
,
32
)
assert_float
Rational
(
20
,
9
)
/
9.8
,
0.22675736961451246
assert_rational
(
Rational
(
1
,
1
),
Rational
(
2
,
3
)
/
Rational
(
2
,
3
)
)
assert_rational
(
Rational
(
900
,
1
),
Rational
(
900
)
/
Rational
(
1
)
)
assert_rational
(
Rational
(
4
,
81
),
Rational
(
-
2
,
9
)
/
Rational
(
-
9
,
2
)
)
assert_rational
(
Rational
(
9
,
32
),
Rational
(
9
,
8
)
/
4
)
assert_float
(
0.22675736961451246
,
Rational
(
20
,
9
)
/
9.8
)
end
assert
'Rational#==, Rational#!='
do
...
...
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