Решение на Осма задача от Христина Тодорова
Обратно към всички решения
Към профила на Христина Тодорова
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 28 успешни тест(а)
- 12 неуспешни тест(а)
Код
Лог от изпълнението
....F....F.....F..F...F..F..F..F....FFFF
Failures:
1) Spreadsheet#to_s returns blank tables as blank strings
Failure/Error: expect(Spreadsheet.new.to_s).to eq ''
expected: ""
got: nil
(compared using ==)
# /tmp/d20160121-5693-1ugfopt/spec.rb:24:in `block (3 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) Spreadsheet#to_s returns the evaluated spreadsheet as a table
Failure/Error: expect(sheet.to_s).to eq \
expected: "foo\t10\t2.1\t15\nbar\t11\t2.2\t5\nbaz\t12\t2.3\t27.60"
got: "foo\t10\t2.10\t15\nbar\t11\t2.20\t5\nbaz\t12\t2.30\t27.60"
(compared using ==)
Diff:
@@ -1,4 +1,4 @@
-foo 10 2.1 15
-bar 11 2.2 5
-baz 12 2.3 27.60
+foo 10 2.10 15
+bar 11 2.20 5
+baz 12 2.30 27.60
# /tmp/d20160121-5693-1ugfopt/spec.rb:50:in `block (3 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) Spreadsheet#[] returns the calculated value of formulae cells
Failure/Error: sheet = Spreadsheet.new "foo\tADD(2, 2)\t=ADD(2, 2)"
TypeError:
no implicit conversion of nil into String
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:99:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:99:in `block (3 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) Spreadsheet#[] raises an exception for less than two arguments passed to ADD
Failure/Error: expect { Spreadsheet.new('=ADD(1)')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'ADD': expected at least 2, got 1/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:119:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:119:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:119:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:119:in `block (3 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) Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY
Failure/Error: expect { Spreadsheet.new('=MULTIPLY(1)')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'MULTIPLY': expected at least 2, got 1/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:149:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:149:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:149:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:149:in `block (3 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) Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments
Failure/Error: expect { Spreadsheet.new('=SUBTRACT(1)')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'SUBTRACT': expected 2, got 1/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:171:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:171:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:171:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:171:in `block (3 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) Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments
Failure/Error: expect { Spreadsheet.new('=DIVIDE(1)')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'DIVIDE': expected 2, got 1/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:195:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:195:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:195:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:195:in `block (3 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) Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments
Failure/Error: expect { Spreadsheet.new('=MOD(1)')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'MOD': expected 2, got 1/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:219:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:219:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:219:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:219:in `block (3 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) Spreadsheet#[] evaluates deeply-nested cell references
Failure/Error: expect(Spreadsheet.new('10 =ADD(5, A1) 3 =DIVIDE(B1, C1) =MOD(D1, 4)')['E1']).to eq '1'
TypeError:
no implicit conversion of nil into String
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:250:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:250:in `block (3 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) Spreadsheet#[] raises an exception for unknown functions
Failure/Error: expect { Spreadsheet.new('=FOO(42) 100')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Unknown function 'FOO'/, got #<TypeError: no implicit conversion of nil into String> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `sub!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:254:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:254:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:254:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:254:in `block (3 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) Spreadsheet#[] raises an exception for missing cells passed as function arguments
Failure/Error: expect { Spreadsheet.new('=ADD(1, B4) 100')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Cell 'B4' does not exist/, got #<NoMethodError: undefined method `[]' for nil:NilClass> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:193:in `get_element'
# /tmp/d20160121-5693-1ugfopt/solution.rb:216:in `text?'
# /tmp/d20160121-5693-1ugfopt/solution.rb:207:in `evaluate'
# /tmp/d20160121-5693-1ugfopt/solution.rb:130:in `block in calculate'
# /tmp/d20160121-5693-1ugfopt/solution.rb:130:in `map!'
# /tmp/d20160121-5693-1ugfopt/solution.rb:130:in `calculate'
# /tmp/d20160121-5693-1ugfopt/solution.rb:205:in `evaluate'
# /tmp/d20160121-5693-1ugfopt/solution.rb:87:in `[]'
# /tmp/d20160121-5693-1ugfopt/spec.rb:260:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:260:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:260:in `block (3 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)>'
12) Spreadsheet#[] raises an exception for invalid expressions
Failure/Error: expect { Spreadsheet.new('=FOO 100')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Invalid expression 'FOO'/, got #<ArgumentError: bad value for range> with backtrace:
# /tmp/d20160121-5693-1ugfopt/solution.rb:48:in `block in adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `times'
# /tmp/d20160121-5693-1ugfopt/solution.rb:46:in `adjust_formulas'
# /tmp/d20160121-5693-1ugfopt/solution.rb:185:in `push_row'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `block in initialize'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `each'
# /tmp/d20160121-5693-1ugfopt/solution.rb:68:in `initialize'
# /tmp/d20160121-5693-1ugfopt/spec.rb:266:in `new'
# /tmp/d20160121-5693-1ugfopt/spec.rb:266:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:266:in `block (3 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)>'
# /tmp/d20160121-5693-1ugfopt/spec.rb:266:in `block (3 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.042 seconds
40 examples, 12 failures
Failed examples:
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:23 # Spreadsheet#to_s returns blank tables as blank strings
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:43 # Spreadsheet#to_s returns the evaluated spreadsheet as a table
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:98 # Spreadsheet#[] returns the calculated value of formulae cells
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:118 # Spreadsheet#[] raises an exception for less than two arguments passed to ADD
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:148 # Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:170 # Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:194 # Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:218 # Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:249 # Spreadsheet#[] evaluates deeply-nested cell references
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:253 # Spreadsheet#[] raises an exception for unknown functions
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:259 # Spreadsheet#[] raises an exception for missing cells passed as function arguments
rspec /tmp/d20160121-5693-1ugfopt/spec.rb:265 # Spreadsheet#[] raises an exception for invalid expressions
История (2 версии и 0 коментара)
Христина обнови решението на 11.01.2016 15:01 (преди около 9 години)
Христина обнови решението на 11.01.2016 17:08 (преди около 9 години)