Решение на Втора задача от Иван Станков
Обратно към всички решения
Към профила на Иван Станков
Резултати
- 3 точки от тестове
- 0 бонус точки
- 3 точки общо
- 10 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
F.FF.FFFF...F..F...F
Failures:
1) #move moves snake up/right/left/down
Failure/Error: expect(move(snake, [1, 0])).to eq([[2, 3], [2, 4], [2, 5], [3, 5]])
expected: [[2, 3], [2, 4], [2, 5], [3, 5]]
got: [[2, 4], [2, 5], [2, 6], [3, 6]]
(compared using ==)
# /tmp/d20151026-15631-o9i7c6/spec.rb:6: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) #move does not mutate the given arguments
Failure/Error: expect { move(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, 3], [2, 4], [2, 5], [2, 6]]
# /tmp/d20151026-15631-o9i7c6/spec.rb:17: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) #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-o9i7c6/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)>'
4) #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-o9i7c6/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)>'
5) #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 nil
# /tmp/d20151026-15631-o9i7c6/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)>'
6) #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 nil:NilClass
# /tmp/d20151026-15631-o9i7c6/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)>'
7) #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 nil:NilClass
# /tmp/d20151026-15631-o9i7c6/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)>'
8) #obstacle_ahead? returns true if snake body ahead
Failure/Error: expect(
expected: true
got: false
(compared using ==)
# /tmp/d20151026-15631-o9i7c6/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)>'
9) #obstacle_ahead? does not mutate the given arguments
Failure/Error: expect { obstacle_ahead?(snake, direction, dimensions) }.not_to change { snake }
result should not have changed, but did change from [[1, 2], [1, 3]] to [[1, 3]]
# /tmp/d20151026-15631-o9i7c6/spec.rb:99: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)>'
10) #danger? does not mutate the given arguments
Failure/Error: expect { danger?(snake, direction, dimensions) }.not_to change { snake }
result should not have changed, but did change from [[1, 2], [1, 3]] to []
# /tmp/d20151026-15631-o9i7c6/spec.rb:123: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.01681 seconds
20 examples, 10 failures
Failed examples:
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:4 # #move moves snake up/right/left/down
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:15 # #move does not mutate the given arguments
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:25 # #grow grows snake up/right/left/down
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:36 # #grow does not mutate the given arguments
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:49 # #new_food generates food on empty position
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:56 # #new_food does not generate food outside of borders (width)
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:60 # #new_food does not generate food outside of borders (height)
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:82 # #obstacle_ahead? returns true if snake body ahead
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:96 # #obstacle_ahead? does not mutate the given arguments
rspec /tmp/d20151026-15631-o9i7c6/spec.rb:120 # #danger? does not mutate the given arguments
История (1 версия и 0 коментара)
Иван обнови решението на 18.10.2015 15:29 (преди над 9 години)