Решение на Втора задача от Любомир Папазов
Обратно към всички решения
Към профила на Любомир Папазов
Резултати
- 3 точки от тестове
- 0 бонус точки
- 3 точки общо
- 9 успешни тест(а)
- 11 неуспешни тест(а)
Код
Лог от изпълнението
......F.FF..FFFFFFFF
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 [3, 3]
# /tmp/d20151026-15631-9e6xn8/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 (height)
Failure/Error: expect(next_food[1]).to be_between(0, dimensions[:height].pred)
expected between?(0, 2) to return true, got false
# /tmp/d20151026-15631-9e6xn8/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)>'
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 [1, 1]
# /tmp/d20151026-15631-9e6xn8/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 true if snake body ahead
Failure/Error: obstacle_ahead?([[5, 5], [4, 5], [4, 4], [5, 4]], [0, 1], dimensions)
NoMethodError:
undefined method `obstacle_ahead?' for #<RSpec::Core::ExampleGroup::Nested_4:0x007f5dc792c558>
# /tmp/d20151026-15631-9e6xn8/spec.rb:84: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 true if wall ahead
Failure/Error: expect(obstacle_ahead?([[8, 8], [8, 9]], [0, 1], dimensions)).to eq true
NoMethodError:
undefined method `obstacle_ahead?' for #<RSpec::Core::ExampleGroup::Nested_4:0x007f5dc790cca8>
# /tmp/d20151026-15631-9e6xn8/spec.rb:89: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) #obstacle_ahead? returns false if no obstacle ahead
Failure/Error: expect(obstacle_ahead?([[3, 4], [3, 5]], [0, 1], dimensions)).to eq false
NoMethodError:
undefined method `obstacle_ahead?' for #<RSpec::Core::ExampleGroup::Nested_4:0x007f5dc7905cf0>
# /tmp/d20151026-15631-9e6xn8/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)>'
7) #obstacle_ahead? does not mutate the given arguments
Failure/Error: expect { obstacle_ahead?(snake, direction, dimensions) }.not_to change { snake }
NoMethodError:
undefined method `obstacle_ahead?' for #<RSpec::Core::ExampleGroup::Nested_4:0x007f5dc79039f0>
# /tmp/d20151026-15631-9e6xn8/spec.rb:99:in `block (3 levels) in <top (required)>'
# /tmp/d20151026-15631-9e6xn8/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)>'
8) #danger? returns true if obstacle in one turn
Failure/Error: expect(danger?([[7, 6], [8, 6], [9, 6]], [1, 0], dimensions)).to eq true
NoMethodError:
undefined method `danger?' for #<RSpec::Core::ExampleGroup::Nested_5:0x007f5dc7901038>
# /tmp/d20151026-15631-9e6xn8/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)>'
9) #danger? returns true if obstacle in two turns
Failure/Error: expect(danger?([[6, 6], [7, 6], [8, 6]], [1, 0], dimensions)).to eq true
NoMethodError:
undefined method `danger?' for #<RSpec::Core::ExampleGroup::Nested_5:0x007f5dc78fea40>
# /tmp/d20151026-15631-9e6xn8/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)>'
10) #danger? returns false if obstacle in three turns
Failure/Error: expect(danger?([[5, 6], [6, 6], [7, 6]], [1, 0], dimensions)).to eq false
NoMethodError:
undefined method `danger?' for #<RSpec::Core::ExampleGroup::Nested_5:0x007f5dc78fcd80>
# /tmp/d20151026-15631-9e6xn8/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)>'
11) #danger? does not mutate the given arguments
Failure/Error: expect { danger?(snake, direction, dimensions) }.not_to change { snake }
NoMethodError:
undefined method `danger?' for #<RSpec::Core::ExampleGroup::Nested_5:0x007f5dc78f9f68>
# /tmp/d20151026-15631-9e6xn8/spec.rb:123:in `block (3 levels) in <top (required)>'
# /tmp/d20151026-15631-9e6xn8/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.01512 seconds
20 examples, 11 failures
Failed examples:
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:49 # #new_food generates food on empty position
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:60 # #new_food does not generate food outside of borders (height)
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:64 # #new_food does not generate food on position where the snake is
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:82 # #obstacle_ahead? returns true if snake body ahead
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:88 # #obstacle_ahead? returns true if wall ahead
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:92 # #obstacle_ahead? returns false if no obstacle ahead
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:96 # #obstacle_ahead? does not mutate the given arguments
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:108 # #danger? returns true if obstacle in one turn
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:112 # #danger? returns true if obstacle in two turns
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:116 # #danger? returns false if obstacle in three turns
rspec /tmp/d20151026-15631-9e6xn8/spec.rb:120 # #danger? does not mutate the given arguments
История (2 версии и 1 коментар)
Любомир обнови решението на 19.10.2015 17:21 (преди над 9 години)
Любомир обнови решението на 19.10.2015 17:29 (преди над 9 години)