Skip to content

Commit

Permalink
Add small runt test for += and *=
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielnrn committed Feb 5, 2024
1 parent e8cb4ba commit 7262a54
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
38 changes: 38 additions & 0 deletions calyx-py/test/par.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import "primitives/core.futil";
component my_comp() -> () {
cells {

}
wires {
group my_group {

}
group my_group2 {

}
group my_group3 {

}
}
control {
par {
seq {
par {
my_group;
my_group2;
my_group3;
my_group2;
my_group3;
}
my_group;
my_group2;
my_group;
my_group3;
}
seq {
my_group2;
my_group3;
}
}
}
}
37 changes: 37 additions & 0 deletions calyx-py/test/par.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is meant to test the `__add__` and `__mul__` functionality of
# the builder's ControlBuilder. In particular we look at `+=` and `*=`
from calyx.builder import (
Builder,
par,
)


def add_par_thing(prog):
my_comp = prog.component("my_comp")

my_group = my_comp.group("my_group")
my_group2 = my_comp.group("my_group2")
my_group3 = my_comp.group("my_group3")

my_par = par(my_group2, my_group3)

my_comp.control *= my_group
# Make sure that an ast.ParComp and CompBuilder par get flattened.
my_comp.control *= my_par
my_comp.control *= par(my_group2, my_group3)
# Turn into seq of par group then [my_group, my_group2]
my_comp.control += [my_group, my_group2]
my_comp.control += my_group
my_comp.control += [my_group3]
# Check going from seq to par block
my_comp.control *= [my_group2, my_group3]


def build():
prog = Builder()
add_par_thing(prog)
return prog.program


if __name__ == "__main__":
build().emit()

0 comments on commit 7262a54

Please sign in to comment.