Gate tests in separate files
This commit is contained in:
parent
1760655308
commit
7476eed452
13
spec/and_spec.rb
Normal file
13
spec/and_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require_relative "../and.rb"
|
||||
describe AndGate do
|
||||
it "should AND together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,0],
|
||||
[1,0,0],
|
||||
[1,1,1],
|
||||
]
|
||||
ok=AndGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
@ -1,9 +1,6 @@
|
||||
require_relative "../port.rb"
|
||||
require_relative "../gate.rb"
|
||||
require_relative "../not.rb"
|
||||
require_relative "../and.rb"
|
||||
require_relative "../or.rb"
|
||||
require_relative "../xor.rb"
|
||||
|
||||
describe Gate do
|
||||
let(:klass) do
|
||||
Class.new(Gate) do
|
||||
@ -34,54 +31,4 @@ describe Gate do
|
||||
b.setval(10)
|
||||
expect(gate.out.val).to eq(18)
|
||||
end
|
||||
|
||||
context "NotGate" do
|
||||
it "should NOT the input" do
|
||||
table=[
|
||||
[0,1],
|
||||
[1,0]
|
||||
]
|
||||
ok=NotGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
context "AndGate" do
|
||||
it "should AND together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,0],
|
||||
[1,0,0],
|
||||
[1,1,1],
|
||||
]
|
||||
ok=AndGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
context "OrGate" do
|
||||
it "should OR together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1],
|
||||
]
|
||||
ok=OrGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
context "XorGate" do
|
||||
it "should XOR together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,1],
|
||||
[1,0,1],
|
||||
[1,1,0],
|
||||
]
|
||||
ok=XorGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
11
spec/not_spec.rb
Normal file
11
spec/not_spec.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "../not.rb"
|
||||
describe NotGate do
|
||||
it "should NOT the input" do
|
||||
table=[
|
||||
[0,1],
|
||||
[1,0]
|
||||
]
|
||||
ok=NotGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
13
spec/or_spec.rb
Normal file
13
spec/or_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require_relative "../or.rb"
|
||||
describe OrGate do
|
||||
it "should OR together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,1],
|
||||
[1,0,1],
|
||||
[1,1,1],
|
||||
]
|
||||
ok=OrGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
13
spec/xor_spec.rb
Normal file
13
spec/xor_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require_relative "../xor.rb"
|
||||
describe XorGate do
|
||||
it "should XOR together all inputs" do
|
||||
table=[
|
||||
[0,0,0],
|
||||
[0,1,1],
|
||||
[1,0,1],
|
||||
[1,1,0],
|
||||
]
|
||||
ok=XorGate.test_table(table)
|
||||
expect(ok).to eq true
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user