From f83dfba2e0f3bf2def0aac826b4cd95f5fe240d5 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 8 May 2020 07:18:18 -0500 Subject: [PATCH] Add tests for gate input width checking --- spec/gate_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/gate_spec.rb b/spec/gate_spec.rb index 416071c..6e43a94 100644 --- a/spec/gate_spec.rb +++ b/spec/gate_spec.rb @@ -10,6 +10,21 @@ describe Gate do end end end + + it "makes sure that all ports have the same width on creation" do + a=Port.new(8) + b=Port.new(7) + expect{klass.new(a,b)}.to raise_error ArgumentError,"Incorrect width 7, expected 8" + end + + it "makes sure that all ports have the same width on adding a port" do + a=Port.new(8) + b=Port.new(8) + gate=klass.new(a,b) + port=Port.new(7) + expect{gate.add_input(port)}.to raise_error ArgumentError,"Incorrect width 7, expected 8" + end + it "calls #inputs_changed when input values change or an input is added" do a=Port.new(8) b=Port.new(8)