Permalink
Browse files

Add mocha and generator methods tests

  • Loading branch information...
1 parent d4ecffb commit 58e6d478e05a2183f1d8a1b7f4f0f43c109d0f41 @txus committed Jun 17, 2011
Showing with 40 additions and 0 deletions.
  1. +1 −0 rexpl.gemspec
  2. +38 −0 test/rexpl/generator_methods_test.rb
  3. +1 −0 test/test_helper.rb
View
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "ansi"
s.add_development_dependency "minitest"
+ s.add_development_dependency "mocha"
s.add_development_dependency 'yard'
s.add_development_dependency 'bluecloth'
@@ -0,0 +1,38 @@
+require 'test_helper'
+
+class GeneratorMethodsTest < MiniTest::Unit::TestCase
+
+ def test_print_debug_info
+ klass = Class.new do
+ dynamic_method :foo do |g|
+ g.push 5
+ g.push 6
+ g.print_debug_info
+ g.ret
+ end
+ end
+ Rexpl::Output.expects(:print_debug_info).with(2, '6')
+ result = klass.new.foo
+ assert_equal result, 6
+ end
+
+ def test_return_stack_returns_an_array_with_stack_cells
+ klass = Class.new do
+ dynamic_method :foo do |g|
+ g.push 3
+ g.push 6
+ g.return_stack
+ g.ret
+ end
+ end
+ assert_equal klass.new.foo, [3, 6]
+ end
+
+ def test_size_returns_size_of_the_stack
+ g = Rubinius::Generator.new
+ g.push 3
+ g.push 5
+ assert_equal 2, g.size
+ end
+
+end
View
@@ -2,5 +2,6 @@
gem 'minitest'
require 'minitest/autorun'
+require 'mocha'
require 'rexpl'

0 comments on commit 58e6d47

Please sign in to comment.