mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-09 09:21:58 +00:00
pyosys: globals, set operators for opaque types
There is so much templating going on that compiling wrappers.cc now takes 1m1.668s on an Apple M4…
This commit is contained in:
parent
384f7431fd
commit
54799bb8be
9 changed files with 343 additions and 47 deletions
42
tests/pyosys/test_set.py
Normal file
42
tests/pyosys/test_set.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from pyosys.libyosys import StringSet, StringPool
|
||||
|
||||
for cls in [StringSet, StringPool]:
|
||||
print(f"Testing {cls.__name__}...")
|
||||
A = cls()
|
||||
A.add("a")
|
||||
|
||||
B = cls()
|
||||
B = A | {"b"}
|
||||
|
||||
assert A < B
|
||||
assert A <= B
|
||||
|
||||
A.add("b")
|
||||
|
||||
assert A == B
|
||||
assert A <= B
|
||||
assert not A < B
|
||||
|
||||
A.add("c")
|
||||
|
||||
assert A > B
|
||||
|
||||
A &= B
|
||||
assert A == B
|
||||
|
||||
Ø = A - B
|
||||
assert len(Ø) == 0
|
||||
|
||||
C = cls({"A", "B", "C"})
|
||||
D = cls()
|
||||
C |= {"A", "B", "C"}
|
||||
D |= {"C", "D", "E"}
|
||||
c_symdiff_d = (C ^ D)
|
||||
assert (c_symdiff_d) == {"A", "B", "D", "E"}
|
||||
|
||||
repr_test = eval(repr(c_symdiff_d))
|
||||
c_symdiff_d == repr_test
|
||||
|
||||
|
||||
print("Done.")
|
Loading…
Add table
Add a link
Reference in a new issue