Skip to content
LIBRARY
Sources.Tests.BooleanStep.md

Sources.Tests.BooleanStep

Test that validates Boolean step signal behavior.

This component creates a test setup for validating the BooleanStep block by connecting its output through a BooleanToReal converter. Both step directions are covered at startTime=0.5:

  • case1: startValue=false, so b2r.y steps 0.0 -> 1.0.

  • case2: startValue=true, so b2r.y steps 1.0 -> 0.0.

Usage

BlockComponents.Sources.Tests.BooleanStep()

Behavior

Source

dyad
"""
Test that validates Boolean step signal behavior.

This component creates a test setup for validating the `BooleanStep` block by
connecting its output through a `BooleanToReal` converter. Both step directions
are covered at `startTime=0.5`:
- `case1`: `startValue=false`, so `b2r.y` steps 0.0 -> 1.0.
- `case2`: `startValue=true`, so `b2r.y` steps 1.0 -> 0.0.
"""
test component BooleanStep
  "Generates a Boolean step signal"
  signal = BlockComponents.Sources.BooleanStep(startTime = 0.5, startValue = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
  "Converts Boolean output to Real for verification"
  b2r = BlockComponents.Math.BooleanToReal() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the Boolean step output to the converter"
  connect(signal.y, b2r.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["b2r.y"]}},
      "case2": {
        "stop": 1,
        "params": {"signal.startValue": true},
        "expect": {"signals": ["b2r.y"]}
      }
    }
  }
}
end
Flattened Source
dyad
"""
Test that validates Boolean step signal behavior.

This component creates a test setup for validating the `BooleanStep` block by
connecting its output through a `BooleanToReal` converter. Both step directions
are covered at `startTime=0.5`:
- `case1`: `startValue=false`, so `b2r.y` steps 0.0 -> 1.0.
- `case2`: `startValue=true`, so `b2r.y` steps 1.0 -> 0.0.
"""
test component BooleanStep
  "Generates a Boolean step signal"
  signal = BlockComponents.Sources.BooleanStep(startTime = 0.5, startValue = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
  "Converts Boolean output to Real for verification"
  b2r = BlockComponents.Math.BooleanToReal() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the Boolean step output to the converter"
  connect(signal.y, b2r.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["b2r.y"]}},
      "case2": {
        "stop": 1,
        "params": {"signal.startValue": true},
        "expect": {"signals": ["b2r.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

Test Case case2

julia
plt