<LocalJumpError> Message: <"no block given">

Cannot understand why this error is being raised. Any help is
appreciated. Please find the code listed below.

def open
  get_connection
end

protected
def  get_connection
  @busy_mutex.synchronize {
    while @free_connections.empty?
      sleep(0.001)
    end
    @free_connections.pop
  }
end

Test

def test_open
assert_nothing_raised @pool.open
end

Error

(in C:/Users/venkat/Documents/Projects/RuBravo/rorm)

  1. Failure:
    test_open(Test_Connection_Provider):
    #Rorm::Connection:0x4dee870. Exception raised: Class:
    Message: <“no block given”> —Backtrace—
    ./test/test_connection_provider.rb:25:in test_open' C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:56:inrun’
    C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:50:in each' C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:50:inrun’
    C:/Users/venkat/.netbeans/6.7/nb_test_runner.rb:63:in start' C:/Users/venkat/.netbeans/6.7/nb_test_runner.rb:99:inrun’

./test/test_connection_provider.rb:25:in `test_open’

Finished in 9.851 seconds.
4 tests, 1 failures, 0 errors

Thanks
Venkat

Venkat A. wrote:

  1. Failure:
    test_open(Test_Connection_Provider):
    #Rorm::Connection:0x4dee870. Exception raised: Class:
    Message: <“no block given”> —Backtrace—
    ./test/test_connection_provider.rb:25:in test_open' C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:56:inrun’
    C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:50:in each' C:/Users/venkat/.netbeans/6.7/nb_suite_runner.rb:50:inrun’
    C:/Users/venkat/.netbeans/6.7/nb_test_runner.rb:63:in start' C:/Users/venkat/.netbeans/6.7/nb_test_runner.rb:99:inrun’

./test/test_connection_provider.rb:25:in `test_open’

def open
yield 2
end

open

–output:–
r1test.rb:2:in `open’: no block given (LocalJumpError)
from r1test.rb:5

On Fri, Sep 4, 2009 at 09:54, Venkat
Akkineni[email protected] wrote:

   @free_connections.pop
 }

end

Test

def test_open

  • assert_nothing_raised @pool.open
  • assert_nothing_raised do
  •  @pool.open
    
  • end

end

assert_nothing_raised requires a block

Jano S. wrote:

On Fri, Sep 4, 2009 at 09:54, Venkat
Akkineni[email protected] wrote:

� � � �@free_connections.pop
� � �}
� �end

Test

�def test_open

  • � �assert_nothing_raised @pool.open
  • assert_nothing_raised do
  •  @pool.open
    
  • end

�end

assert_nothing_raised requires a block

Thanks Jano that was it. Appreciate your help 7stud.

Venkat

7stud – wrote:

def open
yield 2
end

open

–output:–
r1test.rb:2:in `open’: no block given (LocalJumpError)
from r1test.rb:5

Scratch that.

require ‘test/unit’

def open(x)
raise “bad value for x” if x == 0
end

class MyTest < Test::Unit::TestCase
def test_open
assert_nothing_raised open(1)
end
end

–output:–
Loaded suite r1test
Started
F
Finished in 0.008259 seconds.

  1. Failure:
    test_open(MyTest) [r1test.rb:9]:
    Exception raised:
    Class:
    Message: <“no block given”>
    —Backtrace—
    r1test.rb:9:in `test_open’

1 tests, 1 assertions, 1 failures, 0 errors

===========

require ‘test/unit’

def open(x)
raise “bad value for x” if x == 0
end

class MyTest < Test::Unit::TestCase
def test_open
assert_nothing_raised() {open(1)}
end
end

–output:–
Loaded suite r1test
Started
.
Finished in 0.000326 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

========

require ‘test/unit’

def open
1/0
end

class MyTest < Test::Unit::TestCase
def test_open
assert_nothing_raised(ZeroDivisionError) {open}
end
end

–output:–
Loaded suite r1test
Started
F
Finished in 0.008317 seconds.

  1. Failure:
    test_open(MyTest) [r1test.rb:9]:
    Exception raised:
    Class:
    Message: <“divided by 0”>
    —Backtrace—
    r1test.rb:4:in /' r1test.rb:4:inopen’
    r1test.rb:9:in test_open' r1test.rb:9:intest_open’

1 tests, 1 assertions, 1 failures, 0 errors

===========

require ‘test/unit’

def open
1/0
end

class MyTest < Test::Unit::TestCase
def test_open
assert_nothing_raised(RuntimeError) {open}
end
end

–output:–
Loaded suite r1test
Started
E
Finished in 0.000477 seconds.

  1. Error:
    test_open(MyTest):
    ZeroDivisionError: divided by 0
    r1test.rb:4:in /' r1test.rb:4:inopen’
    r1test.rb:9:in test_open' r1test.rb:9:intest_open’

1 tests, 1 assertions, 0 failures, 1 errors

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs