Решение на Осма задача от Марк Андонов
Обратно към всички решения
Към профила на Марк Андонов
Резултати
- 3 точки от тестове
- 0 бонус точки
- 3 точки общо
- 23 успешни тест(а)
- 17 неуспешни тест(а)
Код
Лог от изпълнението
FFF.F....F..F.....F...F..F..F..FFFFFFF..
Failures:
1) Spreadsheet#new can be called with no arguments or with a single string argument
Failure/Error: Spreadsheet.new
ArgumentError:
wrong number of arguments (0 for 1)
# /tmp/d20160121-5693-1rt3eq9/solution.rb:44:in `initialize'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:4:in `new'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:4: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#new creates a blank sheet when no arguments are passed
Failure/Error: expect(Spreadsheet.new).to be_empty
ArgumentError:
wrong number of arguments (0 for 1)
# /tmp/d20160121-5693-1rt3eq9/solution.rb:44:in `initialize'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:10:in `new'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:10: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#new creates a blank sheet when a blank string is passed
Failure/Error: expect(Spreadsheet.new('')).to be_empty
expected empty? to return true, got false
# /tmp/d20160121-5693-1rt3eq9/spec.rb:14: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#to_s returns blank tables as blank strings
Failure/Error: expect(Spreadsheet.new.to_s).to eq ''
ArgumentError:
wrong number of arguments (0 for 1)
# /tmp/d20160121-5693-1rt3eq9/solution.rb:44:in `initialize'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:24:in `new'
# /tmp/d20160121-5693-1rt3eq9/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)>'
5) Spreadsheet#to_s returns the evaluated spreadsheet as a table
Failure/Error: expect(sheet.to_s).to eq \
Spreadsheet::Error:
Invalid cell index '2.9'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:73:in `cell_at'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:87:in `[]'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:17:in `block in set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `map!'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:9:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:55:in `block (2 levels) in to_s'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:55:in `map'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:55:in `block in to_s'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:54:in `each'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:54:in `to_s'
# /tmp/d20160121-5693-1rt3eq9/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)>'
6) Spreadsheet#[] raises an exception for non-existant cells
Failure/Error: expect { Spreadsheet.new()['A1'] }.to raise_error(Spreadsheet::Error, /Cell 'A1' does not exist/)
expected Spreadsheet::Error with message matching /Cell 'A1' does not exist/, got #<ArgumentError: wrong number of arguments (0 for 1)> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:44:in `initialize'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:75:in `new'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:75:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:75: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-1rt3eq9/spec.rb:75: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 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 #<Spreadsheet::Error: Wrong number of arguments for 'ADD':
expected at least 2, got 1> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:110:in `add'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:33:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:119:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
8) 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 #<Spreadsheet::Error: Wrong number of arguments for 'MULTIPLY':
expected at least 2, got 1> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:121:in `multiply'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:33:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:149:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
9) 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 #<Spreadsheet::Error: Wrong number of arguments for 'SUBTRACT':
expected 2, got 1> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:130:in `subtract'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:33:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:171:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
10) 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 #<Spreadsheet::Error: Wrong number of arguments for 'DIVIDE':
expected 2, got 1> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:139:in `divide'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:33:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:195:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
11) 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 #<Spreadsheet::Error: Wrong number of arguments for 'MOD':
expected 2, got 1> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:148:in `mod'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:33:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:219:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
12) Spreadsheet#[] adds floating point numbers with ADD
Failure/Error: expect(Spreadsheet.new('10 =ADD(A1, 1.1)')['B1']).to eq '11.10'
Spreadsheet::Error:
Invalid cell index '1.1'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:73:in `cell_at'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:87:in `[]'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:17:in `block in set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `map!'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:9:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:229: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)>'
13) Spreadsheet#[] subtracts floating point numbers with SUBTRACT
Failure/Error: expect(Spreadsheet.new('10 =SUBTRACT(A1, 1.1)')['B1']).to eq '8.90'
Spreadsheet::Error:
Invalid cell index '1.1'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:73:in `cell_at'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:87:in `[]'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:17:in `block in set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `map!'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:9:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:234: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)>'
14) Spreadsheet#[] multiplies floating point numbers with MULTIPLY
Failure/Error: expect(Spreadsheet.new('10 =MULTIPLY(A1, 1.1)')['B1']).to eq '11'
Spreadsheet::Error:
Invalid cell index '1.1'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:73:in `cell_at'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:87:in `[]'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:17:in `block in set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `map!'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:16:in `set_parameters'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:9:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:239: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)>'
15) Spreadsheet#[] divides floating point numbers with DIVIDE
Failure/Error: expect(Spreadsheet.new('10 =DIVIDE(A1, 4)')['B1']).to eq '2.50'
expected: "2.50"
got: "2.5"
(compared using ==)
# /tmp/d20160121-5693-1rt3eq9/spec.rb:244: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)>'
16) 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'
expected: "1"
got: "15"
(compared using ==)
# /tmp/d20160121-5693-1rt3eq9/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)>'
17) 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 #<NameError: undefined local variable or method `name' for #<Spreadsheet:0x007f06ea9b15c0>> with backtrace:
# /tmp/d20160121-5693-1rt3eq9/solution.rb:35:in `result'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:10:in `formula_string'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:95:in `evaluate_cell'
# /tmp/d20160121-5693-1rt3eq9/solution.rb:88:in `[]'
# /tmp/d20160121-5693-1rt3eq9/spec.rb:254:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-1rt3eq9/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-1rt3eq9/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)>'
Finished in 0.03317 seconds
40 examples, 17 failures
Failed examples:
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:3 # Spreadsheet#new can be called with no arguments or with a single string argument
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:9 # Spreadsheet#new creates a blank sheet when no arguments are passed
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:13 # Spreadsheet#new creates a blank sheet when a blank string is passed
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:23 # Spreadsheet#to_s returns blank tables as blank strings
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:43 # Spreadsheet#to_s returns the evaluated spreadsheet as a table
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:74 # Spreadsheet#[] raises an exception for non-existant cells
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:118 # Spreadsheet#[] raises an exception for less than two arguments passed to ADD
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:148 # Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:170 # Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:194 # Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:218 # Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:228 # Spreadsheet#[] adds floating point numbers with ADD
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:233 # Spreadsheet#[] subtracts floating point numbers with SUBTRACT
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:238 # Spreadsheet#[] multiplies floating point numbers with MULTIPLY
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:243 # Spreadsheet#[] divides floating point numbers with DIVIDE
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:249 # Spreadsheet#[] evaluates deeply-nested cell references
rspec /tmp/d20160121-5693-1rt3eq9/spec.rb:253 # Spreadsheet#[] raises an exception for unknown functions
История (2 версии и 0 коментара)
Марк обнови решението на 11.01.2016 15:47 (преди около 9 години)
Марк обнови решението на 11.01.2016 16:14 (преди около 9 години)