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
769a7e0e
Commit
769a7e0e
authored
May 16, 2012
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle exceptions in tests and reduce syntax features in assert code
parent
f202658d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
18 deletions
+41
-18
test/t/_assert.rb
test/t/_assert.rb
+41
-18
No files found.
test/t/_assert.rb
View file @
769a7e0e
$ok_test
=
0
$ko_test
=
0
$kill_test
=
0
$asserts
=
[]
$exceptions
=
[]
##
# Print the assertion in a readable way
def
print_assertion_string
(
str
,
iso
)
print
(
str
)
if
(
iso
!=
''
)
print
(
' ['
)
print
(
iso
)
print
(
']'
)
end
end
##
# Verify a code block.
...
...
@@ -11,13 +24,18 @@ $asserts = []
# which will be tested by this
# assertion
def
assert
(
str
=
'Assertion failed'
,
iso
=
''
)
begin
if
(
!
yield
)
$asserts
.
push
([
str
,
iso
])
$ko_test
+=
1
print
"F"
print
(
'F'
)
else
$ok_test
+=
1
print
"."
print
(
'.'
)
end
rescue
$kill_test
+=
1
print
(
'X'
)
end
end
...
...
@@ -27,18 +45,23 @@ end
def
report
()
print
"
\n
"
$asserts
.
each
do
|
str
,
iso
|
print
(
"Test Failed:
#{
str
}
[
#{
iso
}
]
\n
"
);
print
(
'Fail: '
);
print_assertion_string
(
str
,
iso
)
print
(
"
\n
"
)
end
$total_test
=
$ok_test
+
$ko_test
print
'Total tests:'
print
$total_test
print
"
\n
"
$total_test
=
$ok_test
.
+
(
$ko_test
)
print
(
'Total: '
)
print
(
$total_test
)
print
(
"
\n
"
)
print
' OK: '
print
$ok_test
print
"
\n
"
print
' KO: '
print
$ko_test
print
"
\n
"
print
(
' OK: '
)
print
(
$ok_test
)
print
(
"
\n
"
)
print
(
' KO: '
)
print
(
$ko_test
)
print
(
"
\n
"
)
print
(
' Crash: '
)
print
(
$kill_test
)
print
(
"
\n
"
)
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