Navigation Menu

Skip to content

Commit

Permalink
Generator proxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Jun 17, 2011
1 parent 4c9e8bc commit 315b8bb
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/rexpl/generator_proxy_test.rb
@@ -0,0 +1,64 @@
require 'test_helper'

class GeneratorProxyTest < MiniTest::Unit::TestCase

def setup
@proxy = Rexpl::GeneratorProxy.new
end

def test_swallows_everything_with_its_args
@proxy.push 3
@proxy.foo
@proxy.bar
@proxy.whatever
@proxy.biwinning

assert_equal 5, @proxy.instructions.size
assert_equal [:push, 3], @proxy.instructions.first
end

def test_visit_executes_the_instructions
@proxy.push 3
@proxy.push_literal 'hey'

g = Rubinius::Generator.new
g.expects(:push).with(3)
g.expects(:push_literal).with('hey')

@proxy.visit(g)
end

def test_reset
@proxy.push 3
@proxy.push 5

Rexpl::Output.expects(:print_reset)

@proxy.reset

assert_equal 0, @proxy.instructions.size
end

def test_list
@proxy.push 3
@proxy.push 5

Rexpl::Output.expects(:print_instruction).with([:push, 3], 0)
Rexpl::Output.expects(:print_instruction).with([:push, 5], 1)

@proxy.list
end

def test_draw
@proxy.push 3
@proxy.push 5
@proxy.meta_send_op_plus 2

Rexpl::Output.expects(:print_stack).with([3])
Rexpl::Output.expects(:print_stack).with([3, 5])
Rexpl::Output.expects(:print_stack).with([8])

@proxy.draw
end

end

0 comments on commit 315b8bb

Please sign in to comment.