Иван обнови решението на 15.01.2014 16:44 (преди почти 11 години)
+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