Add3Test ​
Test the functionality of the Add3 block by connecting three constant inputs.
This test harness connects three constant sources (with values 1, 2, and 3) to an Add3 component and verifies that the output equals the sum of the inputs (6). The test case simulates for 5 seconds and checks the final value of the output.
Usage ​
BlockComponents.Add3Test()
Behavior ​
Source ​
dyad
"""
Test the functionality of the Add3 block by connecting three constant inputs.
This test harness connects three constant sources (with values 1, 2, and 3) to an Add3 component and verifies
that the output equals the sum of the inputs (6). The test case simulates for 5 seconds and checks the final
value of the output.
"""
test component Add3Test
"Constant source with value 1"
c1 = Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 260, "x2": 500, "y2": 360, "rot": 0}
}
}
}
"Constant source with value 2"
c2 = Constant(k = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
}
}
}
"Constant source with value 3"
c3 = Constant(k = 3) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 660, "x2": 500, "y2": 760, "rot": 0}
}
}
}
"Component that adds three inputs"
add3 = Add3() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 640, "y1": 450, "x2": 740, "y2": 550, "rot": 0}
}
}
}
relations
connect(add3.u1, c1.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 590, "y": 470}, {"x": 590, "y": 310}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add3.u2, c2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(add3.u3, c3.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 600, "y": 530}, {"x": 600, "y": 710}], "E": 2}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {"case1": {"stop": 5, "expect": {"final": {"add3.y": 6}}}}
}
}
endFlattened Source
dyad
"""
Test the functionality of the Add3 block by connecting three constant inputs.
This test harness connects three constant sources (with values 1, 2, and 3) to an Add3 component and verifies
that the output equals the sum of the inputs (6). The test case simulates for 5 seconds and checks the final
value of the output.
"""
test component Add3Test
"Constant source with value 1"
c1 = Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 260, "x2": 500, "y2": 360, "rot": 0}
}
}
}
"Constant source with value 2"
c2 = Constant(k = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
}
}
}
"Constant source with value 3"
c3 = Constant(k = 3) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 660, "x2": 500, "y2": 760, "rot": 0}
}
}
}
"Component that adds three inputs"
add3 = Add3() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 640, "y1": 450, "x2": 740, "y2": 550, "rot": 0}
}
}
}
relations
connect(add3.u1, c1.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 590, "y": 470}, {"x": 590, "y": 310}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add3.u2, c2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(add3.u3, c3.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 600, "y": 530}, {"x": 600, "y": 710}], "E": 2}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {"case1": {"stop": 5, "expect": {"final": {"add3.y": 6}}}}
}
}
end