UniSet 2.45.1
Пространство имен tests.test_codegen

Классы

class  TestMinimalProgramStructure
class  TestInputVariableAccess
class  TestOutputVariableAssignment
class  TestLocalVariableDeclaration
class  TestBinaryOperatorMapping
class  TestUnaryOperators
class  TestIfElseEmission
class  TestTypeCoercion
class  TestLiterals
class  TestUnmappedVariableWarning
class  TestIntegrationMinimalPipeline
class  TestCaseEmission
class  TestForLoopEmission
class  TestWhileLoopEmission
class  TestRepeatLoopEmission
class  TestLoadDirectives

Функции

IRProgram _make_program (str name="Main", list|None inputs=None, list|None outputs=None, list|None locals_=None, list|None body=None)
SensorMapping _make_mapping (list[SensorEntry]|None inputs=None, list[SensorEntry]|None outputs=None)

Подробное описание

Tests for the st2js code generator (codegen.py).

Tests cover:
- Minimal program generates correct JS structure
- Input variable access generates in_SensorName
- Output variable assignment generates out_SensorName = ...
- Local variable declaration with initial value
- Binary operator mapping (especially = -> ===, AND -> &&)
- If/else emission
- Type coercion (REAL->INT generates Math.round)
- Complete output for minimal.st + minimal_mapping.yaml

Функции

◆ _make_mapping()

SensorMapping tests.test_codegen._make_mapping ( list[SensorEntry] | None inputs = None,
list[SensorEntry] | None outputs = None )
protected
Helper to create a SensorMapping with defaults.

◆ _make_program()

IRProgram tests.test_codegen._make_program ( str name = "Main",
list | None inputs = None,
list | None outputs = None,
list | None locals_ = None,
list | None body = None )
protected
Helper to create an IRProgram with defaults.