Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1 committed Dec 12, 2015
1 parent 13155dd commit 9ef9fdb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
7 changes: 6 additions & 1 deletion test/test_helper.rb
@@ -1,4 +1,9 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'yomikomu'

require 'tmpdir'

tmpdir = Dir.mktmpdir('yomikomu')
ENV['YOMIKOMU_STORAGE_DIR'] = tmpdir
ENV['YOMIKOMU_STORAGE'] = 'fs2'
require 'yomikomu'
require 'minitest/autorun'
4 changes: 4 additions & 0 deletions test/x.rb
@@ -0,0 +1,4 @@

def yomikomi_test_hello(name)
"hello #{name}"
end
34 changes: 32 additions & 2 deletions test/yomikomu_test.rb
Expand Up @@ -5,7 +5,37 @@ def test_that_it_has_a_version_number
refute_nil ::Yomikomu::VERSION
end

def test_it_does_something_useful
assert false
def test_compile_file
assert_equal 0, ::Yomikomu::STATISTICS[:loaded]
assert_equal 0, ::Yomikomu::STATISTICS[:compiled]
ignored = ::Yomikomu::STATISTICS[:ignored]

Yomikomu::compile_and_store_iseq File.join(__dir__, 'x.rb')
assert_equal 1, ::Yomikomu::STATISTICS[:compiled]

load_file = File.join(__dir__, 'x.rb')

load load_file

assert_equal("hello world", yomikomi_test_hello("world"))
assert_equal 1, ::Yomikomu::STATISTICS[:loaded]
assert_equal 1, ::Yomikomu::STATISTICS[:compiled]

Yomikomu::remove_all_compiled_iseq
load load_file

assert_equal("hello world", yomikomi_test_hello("world"))
assert_equal 1, ::Yomikomu::STATISTICS[:loaded]
assert_equal 1, ::Yomikomu::STATISTICS[:compiled]

Yomikomu::compile_and_store_iseq File.join(__dir__, 'x.rb')
assert_equal 2, ::Yomikomu::STATISTICS[:compiled]

Yomikomu::remove_compiled_iseq load_file
load load_file

assert_equal("hello world", yomikomi_test_hello("world"))
assert_equal 1, ::Yomikomu::STATISTICS[:loaded]
assert_equal 2, ::Yomikomu::STATISTICS[:compiled]
end
end

0 comments on commit 9ef9fdb

Please sign in to comment.