Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract https://github.com/iij/mruby-mtest @ d9f257a00427cac1a96df5a0…
…b8b3bb0dcf2a0966 () at misc/mruby-mtest
- Loading branch information
Ichito Nagata
committed
Aug 15, 2016
1 parent
7986111
commit e3c4bac
Showing
10 changed files
with
928 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule mruby-mtest
deleted from
d9f257
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# mrbgems | ||
*.tmp | ||
*.ctmp | ||
*.rbtmp | ||
*.o | ||
*.a | ||
gem_mixlib.c | ||
gem_mrblib.c | ||
gem_srclib.c | ||
.*.swp | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
script: | ||
- "ruby run_test.rb all test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Minimum Test Framework for mruby | ||
========= | ||
|
||
[![Build Status](https://travis-ci.org/iij/mruby-mtest.svg?branch=master)](https://travis-ci.org/iij/mruby-mtest) | ||
|
||
## example | ||
```ruby | ||
class Test4MTest < MTest::Unit::TestCase | ||
def test_assert | ||
assert(true) | ||
assert(true, 'true sample test') | ||
end | ||
end | ||
|
||
MTest::Unit.new.run | ||
``` | ||
|
||
### How to use mrbgem's mrbtest | ||
```ruby | ||
if Object.const_defined?(:MTest) | ||
class Test4MTest < MTest::Unit::TestCase | ||
def test_assert_nil | ||
assert_nil(nil, 'nil sample test') | ||
end | ||
end | ||
|
||
if $ok_test | ||
MTest::Unit.new.mrbtest | ||
else | ||
MTest::Unit.new.run | ||
end | ||
else | ||
$asserts << "test skip of Test4MTest." if $asserts | ||
end | ||
``` | ||
|
||
## TODO | ||
|
||
- MiniTest::Unit.autorun is not implemented (because mruby hasn't ``at_exit`` method.) | ||
|
||
|
||
## License | ||
|
||
Copyright (c) 2013 Internet Initiative Japan Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class Test4MTest < MTest::Unit::TestCase | ||
def test_assert | ||
assert(true) | ||
assert(true, 'true sample test') | ||
end | ||
|
||
def test_assert_block | ||
assert_block('msg') do | ||
'something-block' | ||
end | ||
end | ||
|
||
def test_assert_empty | ||
assert_empty('', 'string empty') | ||
assert_empty([], 'array empty') | ||
assert_empty({}, 'hash empty') | ||
end | ||
|
||
def test_assert_equal | ||
assert_equal('', nil.to_s) | ||
end | ||
|
||
def test_assert_in_delta | ||
assert_in_delta(0, 0.1, 0.5) | ||
end | ||
|
||
def test_assert_includes | ||
assert_include([1,2,3], 1) | ||
end | ||
|
||
def test_assert_instance_of | ||
assert_instance_of Array, [] | ||
assert_instance_of Class, Array | ||
end | ||
|
||
def test_assert_kind_of | ||
assert_kind_of Array, [] | ||
assert_kind_of Class, Array | ||
end | ||
|
||
def test_assert_match | ||
assert_match 'abc', 'abc' | ||
end | ||
end | ||
|
||
MTest::Unit.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MRuby::Gem::Specification.new('mruby-mtest') do |spec| | ||
spec.license = 'MIT' | ||
spec.authors = 'Internet Initiative Japan Inc.' | ||
|
||
spec.add_dependency 'mruby-sprintf', core: 'mruby-sprintf' | ||
spec.add_dependency 'mruby-time', core: 'mruby-time' | ||
spec.add_dependency 'mruby-io', mgem: 'mruby-io' | ||
end |
Oops, something went wrong.