Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Luc Libralesso
cryptodag
Commits
342b0e33
Commit
342b0e33
authored
Dec 22, 2020
by
Luc Libralesso
Browse files
add triple xor test
parent
bf6c63c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/nodes/exec_xor.rb
View file @
342b0e33
...
...
@@ -27,7 +27,7 @@ class TestExecXorNode < Minitest::Unit::TestCase
assert_equal
(
computed_outputs
,
[
1
,
3
,
0
,
0
])
end
def
test_
simp
le22xor
()
def
test_
doub
le22xor
()
a_node
=
InputNode
.
new
(
name
:"input_a"
,
dimensions
:[
2
,
2
])
b_node
=
InputNode
.
new
(
name
:"input_b"
,
dimensions
:[
2
,
2
])
c_node
=
XorNode
.
new
(
name
:"xor_c"
,
inputs
:[
a_node
.
outputs
[
0
],
b_node
.
outputs
[
0
]])
...
...
@@ -42,4 +42,21 @@ class TestExecXorNode < Minitest::Unit::TestCase
assert_equal
(
computed_outputs
,
[
1
,
1
,
1
,
1
])
end
def
test_triple22xor
()
a_node
=
InputNode
.
new
(
name
:"input_a"
,
dimensions
:[
2
,
2
])
b_node
=
InputNode
.
new
(
name
:"input_b"
,
dimensions
:[
2
,
2
])
c_node
=
XorNode
.
new
(
name
:"xor_c"
,
inputs
:[
a_node
.
outputs
[
0
],
b_node
.
outputs
[
0
]])
d_node
=
InputNode
.
new
(
name
:"input_d"
,
dimensions
:[
2
,
2
])
e_node
=
XorNode
.
new
(
name
:"xor_e"
,
inputs
:[
c_node
.
outputs
[
0
],
d_node
.
outputs
[
0
]])
f_node
=
InputNode
.
new
(
name
:"input_f"
,
dimensions
:[
2
,
2
])
g_node
=
XorNode
.
new
(
name
:"xor_g"
,
inputs
:[
e_node
.
outputs
[
0
],
f_node
.
outputs
[
0
]])
computed_outputs
=
compute_set_of_operators
(
[
1
,
2
,
3
,
4
]
+
[
0
,
1
,
3
,
4
]
+
[
0
,
2
,
1
,
1
]
+
[
1
,
1
,
1
,
1
],
# input values
a_node
.
flatten_output
(
0
)
+
b_node
.
flatten_output
(
0
)
+
d_node
.
flatten_output
(
0
)
+
f_node
.
flatten_output
(
0
),
# input variables
g_node
.
flatten_output
(
0
),
# output variables
e_node
.
operators
+
c_node
.
operators
+
g_node
.
operators
)
assert_equal
(
computed_outputs
,
[
0
,
0
,
0
,
0
])
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment