Skip to content

Commit

Permalink
extract https://github.com/iij/mruby-mtest @ d9f257a00427cac1a96df5a0…
Browse files Browse the repository at this point in the history
…b8b3bb0dcf2a0966 () at misc/mruby-mtest
  • Loading branch information
Ichito Nagata committed Aug 15, 2016
1 parent 7986111 commit e3c4bac
Show file tree
Hide file tree
Showing 10 changed files with 928 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Expand Up @@ -10,6 +10,3 @@
[submodule "misc/cache-digest.js"]
path = misc/cache-digest.js
url = https://github.com/h2o/cache-digest.js.git
[submodule "misc/mruby-mtest"]
path = misc/mruby-mtest
url = https://github.com/iij/mruby-mtest.git
1 change: 0 additions & 1 deletion misc/mruby-mtest
Submodule mruby-mtest deleted from d9f257
11 changes: 11 additions & 0 deletions misc/mruby-mtest/.gitignore
@@ -0,0 +1,11 @@
# mrbgems
*.tmp
*.ctmp
*.rbtmp
*.o
*.a
gem_mixlib.c
gem_mrblib.c
gem_srclib.c
.*.swp
/tmp
2 changes: 2 additions & 0 deletions misc/mruby-mtest/.travis.yml
@@ -0,0 +1,2 @@
script:
- "ruby run_test.rb all test"
63 changes: 63 additions & 0 deletions misc/mruby-mtest/README.md
@@ -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.

46 changes: 46 additions & 0 deletions misc/mruby-mtest/example/sample.rb
@@ -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
8 changes: 8 additions & 0 deletions misc/mruby-mtest/mrbgem.rake
@@ -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

0 comments on commit e3c4bac

Please sign in to comment.