Skip to content

Commit

Permalink
Merge pull request #8 from youchan/add-test
Browse files Browse the repository at this point in the history
Setup Test::Unit
  • Loading branch information
hatappi authored Sep 26, 2017
2 parents eb4ccb2 + af127c1 commit fd8a1cb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
desc "Run tests"
task :test do
ruby("test/run_test.rb")
end

task :default => :spec
task default: :test
2 changes: 1 addition & 1 deletion red-chainer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "test-unit"
end
7 changes: 0 additions & 7 deletions spec/chainer_spec.rb

This file was deleted.

14 changes: 0 additions & 14 deletions spec/spec_helper.rb

This file was deleted.

9 changes: 9 additions & 0 deletions test/functions/math/basic_math_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'chainer'
require 'numo/narray'

class Chainer::Functions::Math::BasicMathTest < Test::Unit::TestCase
test("Neg#forward") do
x = Chainer::Variable.new(Numo::DFloat[[-1, 0],[1, 2]])
assert_equal(Numo::DFloat[[1,0],[-1,-2]], (-x).data)
end
end
9 changes: 9 additions & 0 deletions test/run_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
lib_dir = File.join(base_dir, "lib")
test_dir = File.join(base_dir, "test")

$LOAD_PATH.unshift(lib_dir)

require 'test/unit'

exit Test::Unit::AutoRunner.run(true, test_dir)

0 comments on commit fd8a1cb

Please sign in to comment.