LIBRARY
Sources.Tests.BooleanConstant
Test that validates the BooleanConstant source for both output values.
Two constant Boolean sources — k = true and k = false — are each converted to Real via BooleanToReal so the constant outputs can be snapshotted as trajectories. Expected: toReal_true.y = 1.0 and toReal_false.y = 0.0 for the whole simulation.
Usage
BlockComponents.Sources.Tests.BooleanConstant()
Behavior
Source
dyad
"""
Test that validates the BooleanConstant source for both output values.
Two constant Boolean sources — `k = true` and `k = false` — are each converted to
Real via `BooleanToReal` so the constant outputs can be snapshotted as
trajectories. Expected: `toReal_true.y = 1.0` and `toReal_false.y = 0.0` for the
whole simulation.
"""
test component BooleanConstant
"Constant Boolean source (k = true)"
source_true = BlockComponents.Sources.BooleanConstant(k = true) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
}
}
}
"Converts the true Boolean output to Real"
toReal_true = BlockComponents.Math.BooleanToReal() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 20, "x2": 400, "y2": 120, "rot": 0}
}
}
}
"Constant Boolean source (k = false)"
source_false = BlockComponents.Sources.BooleanConstant(k = false) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 220, "x2": 120, "y2": 320, "rot": 0}
}
}
}
"Converts the false Boolean output to Real"
toReal_false = BlockComponents.Math.BooleanToReal() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 220, "x2": 400, "y2": 320, "rot": 0}
}
}
}
relations
connect(source_true.y, toReal_true.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(source_false.y, toReal_false.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["toReal_true.y", "toReal_false.y"]}}
}
}
}
endFlattened Source
dyad
"""
Test that validates the BooleanConstant source for both output values.
Two constant Boolean sources — `k = true` and `k = false` — are each converted to
Real via `BooleanToReal` so the constant outputs can be snapshotted as
trajectories. Expected: `toReal_true.y = 1.0` and `toReal_false.y = 0.0` for the
whole simulation.
"""
test component BooleanConstant
"Constant Boolean source (k = true)"
source_true = BlockComponents.Sources.BooleanConstant(k = true) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
}
}
}
"Converts the true Boolean output to Real"
toReal_true = BlockComponents.Math.BooleanToReal() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 20, "x2": 400, "y2": 120, "rot": 0}
}
}
}
"Constant Boolean source (k = false)"
source_false = BlockComponents.Sources.BooleanConstant(k = false) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 220, "x2": 120, "y2": 320, "rot": 0}
}
}
}
"Converts the false Boolean output to Real"
toReal_false = BlockComponents.Math.BooleanToReal() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 220, "x2": 400, "y2": 320, "rot": 0}
}
}
}
relations
connect(source_true.y, toReal_true.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(source_false.y, toReal_false.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["toReal_true.y", "toReal_false.y"]}}
}
}
}
endTest Cases
Test Case case1
julia
pltjulia
pltRelated
Examples
Experiments
Analyses
Tests