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
4e9c90ed
Commit
4e9c90ed
authored
Mar 30, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `pass` and `flunk` to `test/assert.rb`
parent
3c732cd2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
test/assert.rb
test/assert.rb
+16
-8
No files found.
test/assert.rb
View file @
4e9c90ed
...
@@ -151,11 +151,11 @@ def assert_float(exp, act, msg = nil)
...
@@ -151,11 +151,11 @@ def assert_float(exp, act, msg = nil)
e
,
a
=
exp
.
to_f
,
act
.
to_f
e
,
a
=
exp
.
to_f
,
act
.
to_f
if
(
e
.
infinite?
||
a
.
infinite?
)
&&
e
!=
a
||
if
(
e
.
infinite?
||
a
.
infinite?
)
&&
e
!=
a
||
e
.
nan?
&&
!
a
.
nan?
||
!
e
.
nan?
&&
a
.
nan?
e
.
nan?
&&
!
a
.
nan?
||
!
e
.
nan?
&&
a
.
nan?
assert_true
(
false
,
msg
,
" Expected
#{
act
}
to be
#{
exp
}
."
)
flunk
(
msg
,
" Expected
#{
act
}
to be
#{
exp
}
."
)
elsif
(
n
=
(
e
-
a
).
abs
)
>
Mrbtest
::
FLOAT_TOLERANCE
elsif
(
n
=
(
e
-
a
).
abs
)
>
Mrbtest
::
FLOAT_TOLERANCE
assert_true
(
false
,
msg
,
" Expected |
#{
exp
}
-
#{
act
}
| (
#{
n
}
) to be <=
#{
Mrbtest
::
FLOAT_TOLERANCE
}
."
)
flunk
(
msg
,
" Expected |
#{
exp
}
-
#{
act
}
| (
#{
n
}
) to be <=
#{
Mrbtest
::
FLOAT_TOLERANCE
}
."
)
else
else
assert_true
(
true
)
pass
end
end
end
end
...
@@ -165,15 +165,15 @@ def assert_raise(*exc)
...
@@ -165,15 +165,15 @@ def assert_raise(*exc)
begin
begin
yield
yield
rescue
*
exc
rescue
*
exc
assert_true
(
true
)
pass
rescue
Exception
=>
e
rescue
Exception
=>
e
diff
=
"
#{
exc
}
exception expected, not
\n
"
\
diff
=
"
#{
exc
}
exception expected, not
\n
"
\
" Class: <
#{
e
.
class
}
>
\n
"
\
" Class: <
#{
e
.
class
}
>
\n
"
\
" Message: <
#{
e
}
>"
" Message: <
#{
e
}
>"
assert_true
(
false
,
msg
,
diff
)
flunk
(
msg
,
diff
)
else
else
diff
=
"
#{
exc
}
expected but nothing was raised."
diff
=
"
#{
exc
}
expected but nothing was raised."
assert_true
(
false
,
msg
,
diff
)
flunk
(
msg
,
diff
)
end
end
end
end
...
@@ -184,12 +184,20 @@ def assert_nothing_raised(msg = nil)
...
@@ -184,12 +184,20 @@ def assert_nothing_raised(msg = nil)
diff
=
" Exception raised:
\n
"
\
diff
=
" Exception raised:
\n
"
\
" Class: <
#{
e
.
class
}
>
\n
"
\
" Class: <
#{
e
.
class
}
>
\n
"
\
" Message: <
#{
e
}
>"
" Message: <
#{
e
}
>"
assert_true
(
false
,
msg
,
diff
)
flunk
(
msg
,
diff
)
else
else
assert_true
(
true
)
pass
end
end
end
end
def
pass
assert_true
(
true
)
end
def
flunk
(
msg
=
nil
,
diff
=
"Epic Fail!"
)
assert_true
(
false
,
msg
,
diff
)
end
##
##
# Report the test result and print all assertions
# Report the test result and print all assertions
# which were reported broken.
# which were reported broken.
...
...
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