Решение на Първа задача от Мая Недялкова
Обратно към всички решения
Към профила на Мая Недялкова
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 12 успешни тест(а)
- 5 неуспешни тест(а)
Код
Лог от изпълнението
FFFFF............
Failures:
1) Array#to_hash converts an array to a hash
Failure/Error: [[:one, 1], [:two, 2]].to_hash.should eq(one: 1, two: 2)
NoMethodError:
undefined method `to_hash' for [[:one, 1], [:two, 2]]:Array
# /tmp/d20111025-2903-1kzev0b/spec.rb:3:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Array#to_hash uses the last pair when a key is present multiple times
Failure/Error: [[1, 2], [3, 4], [1, 3]].to_hash.should eq(1 => 3, 3 => 4)
NoMethodError:
undefined method `to_hash' for [[1, 2], [3, 4], [1, 3]]:Array
# /tmp/d20111025-2903-1kzev0b/spec.rb:7:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Array#to_hash works when the keys and values are arrays
Failure/Error: [[1, [2, 3]], [[4, 5], 6]].to_hash.should eq(1 => [2, 3], [4, 5] => 6)
NoMethodError:
undefined method `to_hash' for [[1, [2, 3]], [[4, 5], 6]]:Array
# /tmp/d20111025-2903-1kzev0b/spec.rb:11:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Array#to_hash works on empty arrays
Failure/Error: [].to_hash.should eq({})
NoMethodError:
undefined method `to_hash' for []:Array
# /tmp/d20111025-2903-1kzev0b/spec.rb:15:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Array#to_hash works with boolean keys
Failure/Error: [nil, 'nil'],
NoMethodError:
undefined method `to_hash' for [[nil, "nil"], [true, "true"], [false, "false"]]:Array
# /tmp/d20111025-2903-1kzev0b/spec.rb:20:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01306 seconds
17 examples, 5 failures
Failed examples:
rspec /tmp/d20111025-2903-1kzev0b/spec.rb:2 # Array#to_hash converts an array to a hash
rspec /tmp/d20111025-2903-1kzev0b/spec.rb:6 # Array#to_hash uses the last pair when a key is present multiple times
rspec /tmp/d20111025-2903-1kzev0b/spec.rb:10 # Array#to_hash works when the keys and values are arrays
rspec /tmp/d20111025-2903-1kzev0b/spec.rb:14 # Array#to_hash works on empty arrays
rspec /tmp/d20111025-2903-1kzev0b/spec.rb:18 # Array#to_hash works with boolean keys
История (1 версия и 0 коментара)
Мая обнови решението на 23.10.2011 22:51 (преди около 13 години)