Решение на Втора задача от Боряна Манолова
Обратно към всички решения
Към профила на Боряна Манолова
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 15 успешни тест(а)
- 5 неуспешни тест(а)
Код
Лог от изпълнението
...F.F...F....F...F.
Failures:
1) #grow grows snake up/right/left/down
Failure/Error: expect(grow(snake, [1, 0])).to eq([[2, 2], [2, 3], [2, 4], [2, 5], [3, 5]])
expected: [[2, 2], [2, 3], [2, 4], [2, 5], [3, 5]]
got: [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 6]]
(compared using ==)
# /tmp/d20151026-15631-idwpij/spec.rb:27: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) #grow does not mutate the given arguments
Failure/Error: expect { grow(snake, direction) }.not_to change { snake }
result should not have changed, but did change from [[2, 2], [2, 3], [2, 4], [2, 5]] to [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6]]
# /tmp/d20151026-15631-idwpij/spec.rb:38: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 on position where the snake is
Failure/Error: expect(snake).not_to include(next_food)
expected [[0, 1], [1, 1], [2, 1], [2, 2]] not to include [2, 1]
# /tmp/d20151026-15631-idwpij/spec.rb:65: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 false if no obstacle ahead
Failure/Error: expect(obstacle_ahead?([[3, 4], [3, 5]], [0, 1], dimensions)).to eq false
expected: false
got: true
(compared using ==)
# /tmp/d20151026-15631-idwpij/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)>'
5) #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: true
(compared using ==)
# /tmp/d20151026-15631-idwpij/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.01783 seconds
20 examples, 5 failures
Failed examples:
rspec /tmp/d20151026-15631-idwpij/spec.rb:25 # #grow grows snake up/right/left/down
rspec /tmp/d20151026-15631-idwpij/spec.rb:36 # #grow does not mutate the given arguments
rspec /tmp/d20151026-15631-idwpij/spec.rb:64 # #new_food does not generate food on position where the snake is
rspec /tmp/d20151026-15631-idwpij/spec.rb:92 # #obstacle_ahead? returns false if no obstacle ahead
rspec /tmp/d20151026-15631-idwpij/spec.rb:116 # #danger? returns false if obstacle in three turns
История (1 версия и 1 коментар)
Боряна обнови решението на 18.10.2015 12:32 (преди над 9 години)