Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple test program raises "undefined method 'gen'". Caused by Claim wanting bblock to return a value? #1

Open
ikedaisuke opened this issue Feb 26, 2011 · 3 comments

Comments

@ikedaisuke
Copy link
Owner

quotes from rubyforge.org as a ticket referred to #15957

http://rubyforge.org/tracker/index.php?func=detail&aid=15957&group_id=2027&atid=7885

Hi,

When I run the below program, I get an "NoMethodError: undefined method 'gen'". I have experimented, and notice
that the problem goes away as soon as I add a statement to the block so it returns a value.

My perception was that RushCheck::Claim does NOT check the block's return value. Is my perception incorrect, or is there
a bug in RushCheck?

Please your comment,

Thanks,

Frank


require 'rushcheck'
require 'test/unit'

def for_all(*cs, &f)
  assert RushCheck::Claim.new(*cs, &f).check
end

class ArrayTest < Test::Unit::TestCase

  def test_array  
    for_all(Integer) do |item|
      array= Array.new
      array.push item
      assert !array.empty? # not ok
    end
  end
end
@ikedaisuke
Copy link
Owner Author

This is a bug. Should be fixed.

@ikedaisuke
Copy link
Owner Author

I grasp where is the bug. The following sample should be worked:

class RushCheckTest < Test::Unit::TestCase
  should "a tiny example" do
    test = Proc.new do |item|
      array = Array.new
      array.push item
      not array.empty?
    end
    RushCheck::Assertion.new(Integer, &test).check
  end
end

Well, I have to rewrite the tutorial...

@ikedaisuke
Copy link
Owner Author

More simply,

class RushCheckTest < Test::Unit::TestCase
  should "a tiny example" do
    RushCheck::Assertion.new(Integer) do |item|
      array = Array.new
      array.push item
      not array.empty?
    end.check
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant