-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #852 from phanrahan/struct-eq
Use Kind.__eq__ for structural equality
- Loading branch information
Showing
12 changed files
with
151 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import magma as m | ||
|
||
|
||
def test_struct_eq(): | ||
assert m.Array[3, m.In(m.Bit)] == m.Array[3, m.Out(m.Bit)], """\ | ||
Direction should not matter when checking structural equality\ | ||
""" | ||
|
||
class T1(m.Product): | ||
x = m.Bit | ||
y = m.Out(m.Bits[1]) | ||
|
||
class T2(m.Product): | ||
x = m.In(m.Bit) | ||
y = m.Bits[1] | ||
assert T1 is not T2, "Different names are not nominally equal" | ||
assert m.Array[3, T1] == m.Array[3, T2], """\ | ||
Products should match structurally, direction does not matter | ||
""" | ||
|
||
class T3(m.Product): | ||
x = m.In(m.Bit) | ||
assert m.Array[3, T1] != m.Array[3, T3], """\ | ||
Missing field should not match | ||
""" | ||
|
||
class T4(m.Product): | ||
x = m.In(m.Bit) | ||
z = m.Bits[1] | ||
assert m.Array[3, T1] != m.Array[3, T4], """\ | ||
Different fields should not match | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters