Skip to content
AddTest.md

AddTest

Adds two constant values to produce a sum of 3.

This component demonstrates basic component composition by connecting two constant sources (with values 1 and 2) to an adder block. The output of the adder (add.y) equals the sum of the two inputs (3).

Usage

AddTest()

Behavior

add.u1(t)=c1.y(t)add.u2(t)=c2.y(t)c1.y(t)=c1.kc2.y(t)=c2.kadd.y(t)=add.k1add.u1(t)+add.k2add.u2(t)

Source

dyad
# Adds two constant values to produce a sum of 3.
#
# This component demonstrates basic component composition by connecting two constant sources
# (with values 1 and 2) to an adder block. The output of the adder (add.y) equals the sum of
# the two inputs (3).
test component AddTest
  # Constant source with value 1
  c1 = Constant(k=1)
  # Constant source with value 2
  c2 = Constant(k=2)
  # Adder that sums its two inputs
  add = Add()
relations
  # Connects the output of constant 1 to the first input of the adder
  connect(add.u1, c1.y)
  # Connects the output of constant 2 to the second input of the adder
  connect(add.u2, c2.y)
metadata {"Dyad": {"tests": {"case1": {"stop": 5, "expect": {"final": {"add.y": 3}}}}}}
end
Flattened Source
dyad
# Adds two constant values to produce a sum of 3.
#
# This component demonstrates basic component composition by connecting two constant sources
# (with values 1 and 2) to an adder block. The output of the adder (add.y) equals the sum of
# the two inputs (3).
test component AddTest
  # Constant source with value 1
  c1 = Constant(k=1)
  # Constant source with value 2
  c2 = Constant(k=2)
  # Adder that sums its two inputs
  add = Add()
relations
  # Connects the output of constant 1 to the first input of the adder
  connect(add.u1, c1.y)
  # Connects the output of constant 2 to the second input of the adder
  connect(add.u2, c2.y)
metadata {"Dyad": {"tests": {"case1": {"stop": 5, "expect": {"final": {"add.y": 3}}}}}}
end


Test Cases

Test Case case1