2012-08-24 9 views
8

probablemente una señal de un aficionado que me pregunto si el problema es el koan (más que yo), sin embargo, considerar este koanRubyKoans: koan roto?

def test_calling_global_methods_without_parentheses 
    result = my_global_method 2, 3 
    assert_equal __, result 
    end 

Nota, el método my_global es

def my_global_method(a,b) 
    a + b 
end 

Esto es la indirecta que me da en la terminal

The answers you seek... 
    <"FILL ME IN"> expected but was <5>. 

así lo hice

def test_calling_global_methods_without_parentheses 
    result = my_global_method 2, 3 
    assert_equal 5, result 
    end 

y me dio este error

Users/mm/Sites/koans/about_methods.rb:21:in `eval': (eval):1: syntax error, unexpected tINTEGER, expecting keyword_do or '{' or '(' (SyntaxError) 
assert_equal 5, my_global_method 2, 3 
           ^
    from /Users/mm/Sites/koans/about_methods.rb:21:in `test_sometimes_missing_parentheses_are_ambiguous' 
    from /Users/mm/Sites/koans/edgecase.rb:377:in `meditate' 
    from /Users/mm/Sites/koans/edgecase.rb:449:in `block in walk' 
    from /Users/mm/Sites/koans/edgecase.rb:460:in `block (3 levels) in each_step' 
    from /Users/mm/Sites/koans/edgecase.rb:458:in `each' 
    from /Users/mm/Sites/koans/edgecase.rb:458:in `block (2 levels) in each_step' 
    from /Users/mm/Sites/koans/edgecase.rb:457:in `each' 
    from /Users/mm/Sites/koans/edgecase.rb:457:in `each_with_index' 
    from /Users/mm/Sites/koans/edgecase.rb:457:in `block in each_step' 
    from /Users/mm/Sites/koans/edgecase.rb:455:in `catch' 
    from /Users/mm/Sites/koans/edgecase.rb:455:in `each_step' 
    from /Users/mm/Sites/koans/edgecase.rb:448:in `walk' 
    from /Users/mm/Sites/koans/edgecase.rb:470:in `block in <top (required)>' 

¿Alguien sabe el problema o me puede decir cómo saltar un koan?

Respuesta

18

Oh, probé este koan. El error está en la línea 21 si lo notó, no en el método "test_calling_global_methods_without_parentheses". Es el método "test_sometimes_missing_parentheses_are_ambiguous" que sale mal como debería ser. Se espera que corrijas ese método.

def test_calling_global_methods_without_parentheses 
    result = my_global_method 2, 3 
    assert_equal 5, result   # You're fine with this koan. 
end 

# (NOTE: We are Using eval below because the example code is 
# considered to be syntactically invalid).     
def test_sometimes_missing_parentheses_are_ambiguous 
    eval "assert_equal 5, my_global_method 2, 3" # ENABLE CHECK 
    # **LOOK HERE~~~ HERE IS THE ERROR YOU SEE** Just correct it. 

Y si hay algún koan usted no sabe cómo hacer frente a, simplemente comentarlo.