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
e36db51b
Unverified
Commit
e36db51b
authored
Mar 24, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Mar 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4337 from shuujii/refactor-t_print-for-test
Refactor `t_print` for test
parents
36c9416b
df4b0813
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
31 deletions
+21
-31
mrbgems/mruby-test/driver.c
mrbgems/mruby-test/driver.c
+13
-21
test/assert.rb
test/assert.rb
+8
-10
No files found.
mrbgems/mruby-test/driver.c
View file @
e36db51b
...
...
@@ -45,29 +45,21 @@ eval_test(mrb_state *mrb)
}
}
static
void
t_printstr
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
char
*
s
;
mrb_int
len
;
if
(
mrb_string_p
(
obj
))
{
s
=
RSTRING_PTR
(
obj
);
len
=
RSTRING_LEN
(
obj
);
fwrite
(
s
,
len
,
1
,
stdout
);
fflush
(
stdout
);
}
}
mrb_value
mrb_t_printstr
(
mrb_state
*
mrb
,
mrb_value
self
)
/* Implementation of print due to the reason that there might be no print */
static
mrb_value
t_print
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
argv
;
mrb_value
*
argv
;
mrb_int
argc
;
mrb_get_args
(
mrb
,
"o"
,
&
argv
);
t_printstr
(
mrb
,
argv
);
mrb_get_args
(
mrb
,
"*!"
,
&
argv
,
&
argc
);
for
(
mrb_int
i
=
0
;
i
<
argc
;
++
i
)
{
mrb_value
s
=
mrb_obj_as_string
(
mrb
,
argv
[
i
]);
fwrite
(
RSTRING_PTR
(
s
),
RSTRING_LEN
(
s
),
1
,
stdout
);
}
fflush
(
stdout
);
return
argv
;
return
mrb_nil_value
()
;
}
void
...
...
@@ -76,7 +68,7 @@ mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose)
struct
RClass
*
krn
,
*
mrbtest
;
krn
=
mrb
->
kernel_module
;
mrb_define_method
(
mrb
,
krn
,
"
__t_printstr__"
,
mrb_t_printstr
,
MRB_ARGS_REQ
(
1
));
mrb_define_method
(
mrb
,
krn
,
"
t_print"
,
t_print
,
MRB_ARGS_ANY
(
));
mrbtest
=
mrb_define_module
(
mrb
,
"Mrbtest"
);
...
...
test/assert.rb
View file @
e36db51b
...
...
@@ -5,14 +5,12 @@ $skip_test = 0
$asserts
=
[]
$test_start
=
Time
.
now
if
Object
.
const_defined?
(
:Time
)
# Implementation of print due to the reason that there might be no print
def
t_print
(
*
args
)
i
=
0
len
=
args
.
size
while
i
<
len
str
=
args
[
i
].
to_s
__t_printstr__
str
rescue
print
str
i
+=
1
unless
RUBY_ENGINE
==
"mruby"
# For bintest on Ruby
def
t_print
(
*
args
)
print
*
args
$stdout
.
flush
nil
end
end
...
...
@@ -110,8 +108,8 @@ def assert_not_equal(exp, act_or_msg = nil, msg = nil, &block)
assert_true
(
!
ret
,
msg
,
diff
)
end
def
assert_same
(
*
args
);
_assert_same
(
true
,
*
args
)
end
def
assert_not_same
(
*
args
);
_assert_same
(
false
,
*
args
)
end
def
assert_same
(
*
args
);
_assert_same
(
true
,
*
args
)
end
def
assert_not_same
(
*
args
);
_assert_same
(
false
,
*
args
)
end
def
_assert_same
(
affirmed
,
exp
,
act
,
msg
=
nil
)
unless
ret
=
exp
.
equal?
(
act
)
==
affirmed
exp_str
,
act_str
=
[
exp
,
act
].
map
do
|
o
|
...
...
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