Решение на Четвърта задача от Николай Каращранов
Обратно към всички решения
Към профила на Николай Каращранов
Резултати
- 0 точки от тестове
- 0 бонус точки
- 0 точки общо
- 0 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
{"ax"=>0, "bx"=>0, "cx"=>0, "dx"=>0}
F{"ax"=>3, "bx"=>4, "cx"=>3, "dx"=>0}
FFFFFFF
Failures:
1) Asm.asm works with empty programs
Failure/Error: Asm.asm {}.should eq [0, 0, 0, 0]
expected: [0, 0, 0, 0]
got: {"ax"=>0, "bx"=>0, "cx"=>0, "dx"=>0}
(compared using ==)
# /tmp/d20140115-8451-16tqisc/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: Asm.asm do
expected: [3, 4, 3, 0]
got: {"ax"=>3, "bx"=>4, "cx"=>3, "dx"=>0}
(compared using ==)
# /tmp/d20140115-8451-16tqisc/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
ArgumentError:
wrong number of arguments (1 for 2)
# /tmp/d20140115-8451-16tqisc/solution.rb:20:in `inc'
# /tmp/d20140115-8451-16tqisc/spec.rb:16:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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: dec ax
ArgumentError:
wrong number of arguments (1 for 2)
# /tmp/d20140115-8451-16tqisc/solution.rb:27:in `dec'
# /tmp/d20140115-8451-16tqisc/spec.rb:25:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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: je 5
ArgumentError:
wrong number of arguments (2 for 1)
# /tmp/d20140115-8451-16tqisc/solution.rb:10:in `method_missing'
# /tmp/d20140115-8451-16tqisc/spec.rb:38:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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: jmp l1
ArgumentError:
wrong number of arguments (2 for 1)
# /tmp/d20140115-8451-16tqisc/solution.rb:10:in `method_missing'
# /tmp/d20140115-8451-16tqisc/spec.rb:70:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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: je l1
ArgumentError:
wrong number of arguments (2 for 1)
# /tmp/d20140115-8451-16tqisc/solution.rb:10:in `method_missing'
# /tmp/d20140115-8451-16tqisc/spec.rb:81:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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: label cycle
ArgumentError:
wrong number of arguments (2 for 1)
# /tmp/d20140115-8451-16tqisc/solution.rb:10:in `method_missing'
# /tmp/d20140115-8451-16tqisc/spec.rb:92:in `block (3 levels) in <top (required)>'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `instance_eval'
# /tmp/d20140115-8451-16tqisc/solution.rb:44:in `asm'
# /tmp/d20140115-8451-16tqisc/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.00832 seconds
8 examples, 8 failures
Failed examples:
rspec /tmp/d20140115-8451-16tqisc/spec.rb:2 # Asm.asm works with empty programs
rspec /tmp/d20140115-8451-16tqisc/spec.rb:6 # Asm.asm implements MOV
rspec /tmp/d20140115-8451-16tqisc/spec.rb:14 # Asm.asm implements INC
rspec /tmp/d20140115-8451-16tqisc/spec.rb:22 # Asm.asm implements DEC
rspec /tmp/d20140115-8451-16tqisc/spec.rb:33 # Asm.asm implements CMP
rspec /tmp/d20140115-8451-16tqisc/spec.rb:67 # Asm.asm implements JMP
rspec /tmp/d20140115-8451-16tqisc/spec.rb:77 # Asm.asm implements LABEL
rspec /tmp/d20140115-8451-16tqisc/spec.rb:88 # Asm.asm can be used to find GCD of two numbers
История (1 версия и 2 коментара)
Николай обнови решението на 15.01.2014 12:36 (преди почти 11 години)