Решение на Четвърта задача от Иван Иванов

Обратно към всички решения

Към профила на Иван Иванов

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 8 неуспешни тест(а)

Код

class Asm
def self.asm(&block)
yield
end
end

Лог от изпълнението

FFFFFFFF

Failures:

  1) Asm.asm works with empty programs
     Failure/Error: Asm.asm {}.should eq [0, 0, 0, 0]
       
       expected: [0, 0, 0, 0]
            got: nil
       
       (compared using ==)
     # /tmp/d20140115-8451-4aygsz/spec.rb:3:in `block (2 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) Asm.asm implements MOV
     Failure/Error: mov ax, 3
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb9407dc4>
     # /tmp/d20140115-8451-4aygsz/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:7:in `block (2 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) Asm.asm implements INC
     Failure/Error: inc ax
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb9406eb0>
     # /tmp/d20140115-8451-4aygsz/spec.rb:16:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:15:in `block (2 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) Asm.asm implements DEC
     Failure/Error: mov ax, 3
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb9405efc>
     # /tmp/d20140115-8451-4aygsz/spec.rb:24:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:23:in `block (2 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) Asm.asm implements CMP
     Failure/Error: mov ax, 2
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb9404b38>
     # /tmp/d20140115-8451-4aygsz/spec.rb:35:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:34:in `block (2 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) Asm.asm implements JMP
     Failure/Error: mov cx, 1
     NameError:
       undefined local variable or method `cx' for #<RSpec::Core::ExampleGroup::Nested_1:0xb91afc0c>
     # /tmp/d20140115-8451-4aygsz/spec.rb:69:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:68:in `block (2 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) Asm.asm implements LABEL
     Failure/Error: mov ax, 1
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb91aebf4>
     # /tmp/d20140115-8451-4aygsz/spec.rb:79:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:78:in `block (2 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) Asm.asm can be used to find GCD of two numbers
     Failure/Error: mov ax, 40
     NameError:
       undefined local variable or method `ax' for #<RSpec::Core::ExampleGroup::Nested_1:0xb91acd68>
     # /tmp/d20140115-8451-4aygsz/spec.rb:90:in `block (3 levels) in <top (required)>'
     # /tmp/d20140115-8451-4aygsz/solution.rb:3:in `asm'
     # /tmp/d20140115-8451-4aygsz/spec.rb:89:in `block (2 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.02992 seconds
8 examples, 8 failures

Failed examples:

rspec /tmp/d20140115-8451-4aygsz/spec.rb:2 # Asm.asm works with empty programs
rspec /tmp/d20140115-8451-4aygsz/spec.rb:6 # Asm.asm implements MOV
rspec /tmp/d20140115-8451-4aygsz/spec.rb:14 # Asm.asm implements INC
rspec /tmp/d20140115-8451-4aygsz/spec.rb:22 # Asm.asm implements DEC
rspec /tmp/d20140115-8451-4aygsz/spec.rb:33 # Asm.asm implements CMP
rspec /tmp/d20140115-8451-4aygsz/spec.rb:67 # Asm.asm implements JMP
rspec /tmp/d20140115-8451-4aygsz/spec.rb:77 # Asm.asm implements LABEL
rspec /tmp/d20140115-8451-4aygsz/spec.rb:88 # Asm.asm can be used to find GCD of two numbers

История (1 версия и 0 коментара)

Иван обнови решението на 15.01.2014 16:44 (преди почти 11 години)

+class Asm
+ def self.asm(&block)
+ yield
+ end
+end