Решение на Осма задача от Виктор Радивчев
Обратно към всички решения
Към профила на Виктор Радивчев
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 28 успешни тест(а)
- 12 неуспешни тест(а)
Код
Лог от изпълнението
.........F........F...F..F..FFF.FFFF...F
Failures:
1) Spreadsheet#to_s returns the evaluated spreadsheet as a table
Failure/Error: expect(sheet.to_s).to eq \
Spreadsheet::Error:
Invalid expression 'ADD(B1, C1, 2.9)'
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/solution.rb:154:in `block (2 levels) in to_s'
# /tmp/d20160121-5693-13s1qg5/solution.rb:153:in `map'
# /tmp/d20160121-5693-13s1qg5/solution.rb:153:in `with_index'
# /tmp/d20160121-5693-13s1qg5/solution.rb:153:in `block in to_s'
# /tmp/d20160121-5693-13s1qg5/solution.rb:152:in `map'
# /tmp/d20160121-5693-13s1qg5/solution.rb:152:in `with_index'
# /tmp/d20160121-5693-13s1qg5/solution.rb:152:in `to_s'
# /tmp/d20160121-5693-13s1qg5/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)>'
2) Spreadsheet#[] raises an exception for less than two arguments passed to ADD
Failure/Error: expect { Spreadsheet.new('=ADD()')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'ADD': expected at least 2, got 0/, got #<Spreadsheet::Error: Invalid expression 'ADD()'> with backtrace:
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:123:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-13s1qg5/spec.rb:123: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-13s1qg5/spec.rb:123: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#[] raises an exception for less than two arguments to MULTIPLY
Failure/Error: expect { Spreadsheet.new('=MULTIPLY()')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Wrong number of arguments for 'MULTIPLY': expected at least 2, got 0/, got #<Spreadsheet::Error: Invalid expression 'MULTIPLY()'> with backtrace:
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:153:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-13s1qg5/spec.rb:153: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-13s1qg5/spec.rb:153: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 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 at least 2, got 1> with backtrace:
# /tmp/d20160121-5693-13s1qg5/solution.rb:22:in `subtract'
# /tmp/d20160121-5693-13s1qg5/solution.rb:49:in `calculate'
# /tmp/d20160121-5693-13s1qg5/solution.rb:66:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:171:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-13s1qg5/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-13s1qg5/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)>'
5) 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 at least 2, got 1> with backtrace:
# /tmp/d20160121-5693-13s1qg5/solution.rb:30:in `divide'
# /tmp/d20160121-5693-13s1qg5/solution.rb:50:in `calculate'
# /tmp/d20160121-5693-13s1qg5/solution.rb:66:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:195:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-13s1qg5/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-13s1qg5/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)>'
6) Spreadsheet#[] calculates the modulo of two numbers with MOD
Failure/Error: expect(Spreadsheet.new('=MOD(42, 5)')['A1']).to eq('2')
expected: "2"
got: "8"
(compared using ==)
# /tmp/d20160121-5693-13s1qg5/spec.rb:205: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#[] calculates the modulo of two numbers with MOD via cell references
Failure/Error: expect(sheet1['C1']).to eq('4')
expected: "4"
got: "8"
(compared using ==)
# /tmp/d20160121-5693-13s1qg5/spec.rb:214: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#[] adds floating point numbers with ADD
Failure/Error: expect(Spreadsheet.new('10 =ADD(A1, 1.1)')['B1']).to eq '11.10'
Spreadsheet::Error:
Invalid expression 'ADD(A1, 1.1)'
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/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)>'
9) 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 expression 'SUBTRACT(A1, 1.1)'
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/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)>'
10) Spreadsheet#[] multiplies floating point numbers with MULTIPLY
Failure/Error: expect(Spreadsheet.new('10 =MULTIPLY(A1, 1.1)')['B1']).to eq '11'
Spreadsheet::Error:
Invalid expression 'MULTIPLY(A1, 1.1)'
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/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)>'
11) Spreadsheet#[] divides floating point numbers with DIVIDE
Failure/Error: expect(Spreadsheet.new('10 =DIVIDE(A1, 4.0)')['B1']).to eq '2.50'
Spreadsheet::Error:
Invalid expression 'DIVIDE(A1, 4.0)'
# /tmp/d20160121-5693-13s1qg5/solution.rb:117:in `check_valid_function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:61:in `function'
# /tmp/d20160121-5693-13s1qg5/solution.rb:182:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:245: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 A1 100')['A1'] }.to raise_error(
expected Spreadsheet::Error with message matching /Invalid expression 'FOO A1'/, got #<Spreadsheet::Error: Invalid cell index 'FOO A1'> with backtrace:
# /tmp/d20160121-5693-13s1qg5/solution.rb:107:in `check_valid_cell'
# /tmp/d20160121-5693-13s1qg5/solution.rb:166:in `cell_at'
# /tmp/d20160121-5693-13s1qg5/solution.rb:176:in `[]'
# /tmp/d20160121-5693-13s1qg5/solution.rb:179:in `[]'
# /tmp/d20160121-5693-13s1qg5/spec.rb:274:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-13s1qg5/spec.rb:274: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-13s1qg5/spec.rb:274: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.03188 seconds
40 examples, 12 failures
Failed examples:
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:43 # Spreadsheet#to_s returns the evaluated spreadsheet as a table
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:118 # Spreadsheet#[] raises an exception for less than two arguments passed to ADD
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:148 # Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:170 # Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:194 # Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:204 # Spreadsheet#[] calculates the modulo of two numbers with MOD
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:210 # Spreadsheet#[] calculates the modulo of two numbers with MOD via cell references
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:228 # Spreadsheet#[] adds floating point numbers with ADD
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:233 # Spreadsheet#[] subtracts floating point numbers with SUBTRACT
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:238 # Spreadsheet#[] multiplies floating point numbers with MULTIPLY
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:243 # Spreadsheet#[] divides floating point numbers with DIVIDE
rspec /tmp/d20160121-5693-13s1qg5/spec.rb:265 # Spreadsheet#[] raises an exception for invalid expressions
История (2 версии и 0 коментара)
Виктор обнови решението на 10.01.2016 19:03 (преди около 9 години)
Виктор обнови решението на 10.01.2016 22:38 (преди около 9 години)