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
d8c8893e
Commit
d8c8893e
authored
Jun 15, 2013
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement assert_float and add block mode to assert_equal and assert_not_equal
parent
cbc9c24f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
test/assert.rb
test/assert.rb
+23
-3
No files found.
test/assert.rb
View file @
d8c8893e
...
...
@@ -62,7 +62,7 @@ def assert(str = 'Assertion failed', iso = '')
$asserts
.
push
(
assertion_string
(
'Error: '
,
str
,
iso
,
e
))
$kill_test
+=
1
t_print
(
'X'
)
end
end
ensure
$mrbtest_assert
=
nil
end
...
...
@@ -99,13 +99,25 @@ def assert_false(ret, msg = nil, diff = nil)
!
ret
end
def
assert_equal
(
exp
,
act
,
msg
=
nil
)
def
assert_equal
(
arg1
,
arg2
=
nil
,
arg3
=
nil
)
if
block_given?
exp
,
act
,
msg
=
yield
,
arg1
,
arg2
else
exp
,
act
,
msg
=
arg1
,
arg2
,
arg3
end
msg
=
"Expected to be equal"
unless
msg
diff
=
assertion_diff
(
exp
,
act
)
assert_true
(
exp
==
act
,
msg
,
diff
)
end
def
assert_not_equal
(
exp
,
act
,
msg
=
nil
)
def
assert_not_equal
(
arg1
,
arg2
=
nil
,
arg3
=
nil
)
if
block_given?
exp
,
act
,
msg
=
yield
,
arg1
,
arg2
else
exp
,
act
,
msg
=
arg1
,
arg2
,
arg3
end
msg
=
"Expected to be not equal"
unless
msg
diff
=
assertion_diff
(
exp
,
act
)
assert_false
(
exp
==
act
,
msg
,
diff
)
...
...
@@ -169,6 +181,14 @@ def assert_kind_of(cls, obj, msg = nil)
assert_true
(
obj
.
kind_of?
(
cls
),
msg
,
diff
)
end
##
# Fails unless +exp+ is equal to +act+ in terms of a Float
def
assert_float
(
exp
,
act
,
msg
=
nil
)
msg
=
"Float
#{
exp
}
expected to be equal to float
#{
act
}
"
unless
msg
diff
=
assertion_diff
(
exp
,
act
)
assert_true
check_float
(
exp
,
act
),
msg
,
diff
end
##
# Report the test result and print all assertions
# 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