Решение на Осма задача от Кузман Белев
Обратно към всички решения
Към профила на Кузман Белев
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 26 успешни тест(а)
- 14 неуспешни тест(а)
Код
Лог от изпълнението
▸ Покажи лога....F...FF........F...F..F..F..FFFFF.F.F
Failures:
1) Spreadsheet#to_s returns blank tables as blank strings
Failure/Error: expect(Spreadsheet.new.to_s).to eq ''
NoMethodError:
undefined method `cell_id' for nil:NilClass
# /tmp/d20160121-5693-90hdk8/solution.rb:74:in `to_s'
# /tmp/d20160121-5693-90hdk8/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 splits cells by two or more spaces
Failure/Error: expect(Spreadsheet.new("foo bar 42\nbaz larodi 100").to_s).to eq "foo\tbar\t42\nbaz\tlarodi\t100"
expected: "foo\tbar\t42\nbaz\tlarodi\t100"
got: "foo\tbar\t 42\nbaz\tlarodi\t100"
(compared using ==)
Diff:
@@ -1,3 +1,3 @@
-foo bar 42
+foo bar 42
baz larodi 100
# /tmp/d20160121-5693-90hdk8/spec.rb:40: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#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\t 10\t2.1\t =ADD(B1, C1, 2.9)\nbar\t 11\t2.2\t =DIVIDE(B2, C2)\nbaz\t 12\t2.3\t =MULTIPLY(C3, B3)"
(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.1 =ADD(B1, C1, 2.9)
+bar 11 2.2 =DIVIDE(B2, C2)
+baz 12 2.3 =MULTIPLY(C3, B3)
# /tmp/d20160121-5693-90hdk8/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)>'
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/ but nothing was raised
# /tmp/d20160121-5693-90hdk8/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/ but nothing was raised
# /tmp/d20160121-5693-90hdk8/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/ but nothing was raised
# /tmp/d20160121-5693-90hdk8/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 #<NoMethodError: undefined method `match' for nil:NilClass> with backtrace:
# /tmp/d20160121-5693-90hdk8/solution.rb:65:in `[]'
# /tmp/d20160121-5693-90hdk8/solution.rb:97:in `calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/spec.rb:195:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-90hdk8/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-90hdk8/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/ but nothing was raised
# /tmp/d20160121-5693-90hdk8/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#[] 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-90hdk8/solution.rb:108:in `exception_thrower'
# /tmp/d20160121-5693-90hdk8/solution.rb:66:in `[]'
# /tmp/d20160121-5693-90hdk8/solution.rb:100:in `block in calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `map'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/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)>'
10) 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-90hdk8/solution.rb:108:in `exception_thrower'
# /tmp/d20160121-5693-90hdk8/solution.rb:66:in `[]'
# /tmp/d20160121-5693-90hdk8/solution.rb:100:in `block in calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `map'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/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)>'
11) 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-90hdk8/solution.rb:108:in `exception_thrower'
# /tmp/d20160121-5693-90hdk8/solution.rb:66:in `[]'
# /tmp/d20160121-5693-90hdk8/solution.rb:100:in `block in calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `map'
# /tmp/d20160121-5693-90hdk8/solution.rb:99:in `calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/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)>'
12) 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-90hdk8/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)>'
13) 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 #<NoMethodError: undefined method `to_sym' for nil:NilClass> with backtrace:
# /tmp/d20160121-5693-90hdk8/solution.rb:101:in `calculate'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/spec.rb:254:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-90hdk8/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-90hdk8/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)>'
14) 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 #<NoMethodError: undefined method `split' for nil:NilClass> with backtrace:
# /tmp/d20160121-5693-90hdk8/solution.rb:23:in `return_parameters'
# /tmp/d20160121-5693-90hdk8/solution.rb:70:in `[]'
# /tmp/d20160121-5693-90hdk8/spec.rb:266:in `block (4 levels) in <top (required)>'
# /tmp/d20160121-5693-90hdk8/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-90hdk8/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.04167 seconds
40 examples, 14 failures
Failed examples:
rspec /tmp/d20160121-5693-90hdk8/spec.rb:23 # Spreadsheet#to_s returns blank tables as blank strings
rspec /tmp/d20160121-5693-90hdk8/spec.rb:39 # Spreadsheet#to_s splits cells by two or more spaces
rspec /tmp/d20160121-5693-90hdk8/spec.rb:43 # Spreadsheet#to_s returns the evaluated spreadsheet as a table
rspec /tmp/d20160121-5693-90hdk8/spec.rb:118 # Spreadsheet#[] raises an exception for less than two arguments passed to ADD
rspec /tmp/d20160121-5693-90hdk8/spec.rb:148 # Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY
rspec /tmp/d20160121-5693-90hdk8/spec.rb:170 # Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments
rspec /tmp/d20160121-5693-90hdk8/spec.rb:194 # Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments
rspec /tmp/d20160121-5693-90hdk8/spec.rb:218 # Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments
rspec /tmp/d20160121-5693-90hdk8/spec.rb:228 # Spreadsheet#[] adds floating point numbers with ADD
rspec /tmp/d20160121-5693-90hdk8/spec.rb:233 # Spreadsheet#[] subtracts floating point numbers with SUBTRACT
rspec /tmp/d20160121-5693-90hdk8/spec.rb:238 # Spreadsheet#[] multiplies floating point numbers with MULTIPLY
rspec /tmp/d20160121-5693-90hdk8/spec.rb:243 # Spreadsheet#[] divides floating point numbers with DIVIDE
rspec /tmp/d20160121-5693-90hdk8/spec.rb:253 # Spreadsheet#[] raises an exception for unknown functions
rspec /tmp/d20160121-5693-90hdk8/spec.rb:265 # Spreadsheet#[] raises an exception for invalid expressions
История (6 версии и 1 коментар)
Кузман обнови решението на 09.01.2016 23:04 (преди около 9 години)
▸ Покажи разликите
Кузман обнови решението на 11.01.2016 15:56 (преди около 9 години)
▸ Покажи разликите
Кузман обнови решението на 11.01.2016 16:31 (преди около 9 години)
▸ Покажи разликите
Кузман обнови решението на 11.01.2016 16:43 (преди около 9 години)
▸ Покажи разликите
Кузман обнови решението на 11.01.2016 17:09 (преди около 9 години)
▸ Покажи разликите
Кузман обнови решението на 11.01.2016 17:09 (преди около 9 години)
▸ Покажи разликите