Решение на Втора задача от Евгени Калчев
Обратно към всички решения
Към профила на Евгени Калчев
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 12 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
......FFF...F.F.FFF.
Failures:
1) #new_food generates food on empty position
Failure/Error: expect(empty_positions).to include(next_food)
expected [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]] to include //
# /tmp/d20151026-15631-1l4zl2h/spec.rb:53:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) #new_food does not generate food outside of borders (width)
Failure/Error: expect(next_food[0]).to be_between(0, dimensions[:width].pred)
NoMethodError:
undefined method `[]' for //:Regexp
# /tmp/d20151026-15631-1l4zl2h/spec.rb:57:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) #new_food does not generate food outside of borders (height)
Failure/Error: expect(next_food[1]).to be_between(0, dimensions[:height].pred)
NoMethodError:
undefined method `[]' for //:Regexp
# /tmp/d20151026-15631-1l4zl2h/spec.rb:61:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) #obstacle_ahead? returns true if snake body ahead
Failure/Error: expect(
expected: true
got: nil
(compared using ==)
# /tmp/d20151026-15631-1l4zl2h/spec.rb:83:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) #obstacle_ahead? returns false if no obstacle ahead
Failure/Error: expect(obstacle_ahead?([[3, 4], [3, 5]], [0, 1], dimensions)).to eq false
expected: false
got: nil
(compared using ==)
# /tmp/d20151026-15631-1l4zl2h/spec.rb:93:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) #danger? returns true if obstacle in one turn
Failure/Error: expect(danger?([[7, 6], [8, 6], [9, 6]], [1, 0], dimensions)).to eq true
expected: true
got: nil
(compared using ==)
# /tmp/d20151026-15631-1l4zl2h/spec.rb:109:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) #danger? returns true if obstacle in two turns
Failure/Error: expect(danger?([[6, 6], [7, 6], [8, 6]], [1, 0], dimensions)).to eq true
expected: true
got: nil
(compared using ==)
# /tmp/d20151026-15631-1l4zl2h/spec.rb:113:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) #danger? returns false if obstacle in three turns
Failure/Error: expect(danger?([[5, 6], [6, 6], [7, 6]], [1, 0], dimensions)).to eq false
expected: false
got: nil
(compared using ==)
# /tmp/d20151026-15631-1l4zl2h/spec.rb:117:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01185 seconds
20 examples, 8 failures
Failed examples:
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:49 # #new_food generates food on empty position
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:56 # #new_food does not generate food outside of borders (width)
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:60 # #new_food does not generate food outside of borders (height)
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:82 # #obstacle_ahead? returns true if snake body ahead
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:92 # #obstacle_ahead? returns false if no obstacle ahead
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:108 # #danger? returns true if obstacle in one turn
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:112 # #danger? returns true if obstacle in two turns
rspec /tmp/d20151026-15631-1l4zl2h/spec.rb:116 # #danger? returns false if obstacle in three turns
История (3 версии и 1 коментар)
Евгени обнови решението на 18.10.2015 22:11 (преди над 9 години)
Евгени обнови решението на 19.10.2015 16:09 (преди над 9 години)
Евгени обнови решението на 19.10.2015 16:10 (преди над 9 години)