Решение на Втора задача от Веселин Стоянов
Обратно към всички решения
Към профила на Веселин Стоянов
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 15 успешни тест(а)
- 5 неуспешни тест(а)
Код
Лог от изпълнението
FFFF.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-1nl9uaj/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 moves one-position-sized snake
Failure/Error: expect(move([[2, 2]], [-1, 0])).to eq([[1, 2]])
NoMethodError:
undefined method `[]' for nil:NilClass
# /tmp/d20151026-15631-1nl9uaj/solution.rb:4:in `move'
# /tmp/d20151026-15631-1nl9uaj/spec.rb:12: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) #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-1nl9uaj/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)>'
4) #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-1nl9uaj/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)>'
5) #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-1nl9uaj/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)>'
Finished in 0.01459 seconds
20 examples, 5 failures
Failed examples:
rspec /tmp/d20151026-15631-1nl9uaj/spec.rb:4 # #move moves snake up/right/left/down
rspec /tmp/d20151026-15631-1nl9uaj/spec.rb:11 # #move moves one-position-sized snake
rspec /tmp/d20151026-15631-1nl9uaj/spec.rb:15 # #move does not mutate the given arguments
rspec /tmp/d20151026-15631-1nl9uaj/spec.rb:25 # #grow grows snake up/right/left/down
rspec /tmp/d20151026-15631-1nl9uaj/spec.rb:36 # #grow does not mutate the given arguments
История (1 версия и 0 коментара)
Веселин обнови решението на 18.10.2015 15:51 (преди над 9 години)