mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-10 01:41:59 +00:00
pyosys: fix ref-only classes, implicit conversions
+ cleanup
This commit is contained in:
parent
c8404bf86b
commit
80fcce64da
7 changed files with 122 additions and 67 deletions
|
@ -1,11 +1,11 @@
|
|||
from pyosys import libyosys as ys
|
||||
|
||||
my_idict = ys.IdstringIdict()
|
||||
print(my_idict(ys.IdString("\\hello")))
|
||||
print(my_idict(ys.IdString("\\world")))
|
||||
print(my_idict.get(ys.IdString("\\world")))
|
||||
print(my_idict(ys.IdString("\\hello"))) # test explicit IdString construction
|
||||
print(my_idict("\\world"))
|
||||
print(my_idict.get("\\world"))
|
||||
try:
|
||||
print(my_idict.get(ys.IdString("\\dummy")))
|
||||
print(my_idict.get("\\dummy"))
|
||||
except IndexError as e:
|
||||
print(f"{repr(e)}")
|
||||
print(my_idict[0])
|
||||
|
@ -22,10 +22,10 @@ current_len = len(my_idict)
|
|||
assert current_len == 2, "copy"
|
||||
|
||||
my_copy = my_idict.copy()
|
||||
my_copy(ys.IdString("\\copy"))
|
||||
my_copy("\\copy")
|
||||
assert len(my_idict) == current_len, "copy seemed to have mutate original idict"
|
||||
assert len(my_copy) == current_len + 1, "copy not behaving as expected"
|
||||
|
||||
current_copy_len = len(my_copy)
|
||||
my_copy |= (ys.IdString(e) for e in ("\\the", "\\world")) # 1 new element
|
||||
my_copy |= ("\\the", "\\world") # 1 new element
|
||||
assert len(my_copy) == current_copy_len + 1, "or operator returned unexpected result"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue