Exemplo n.º 1
0
    def test_either(self) -> None:
        builder = EitherBuilder(Skip(), Skip())

        assert_that(
            str(builder),
            is_(
                equal_to(
                    dedent("""\
                either
                  skip;
                  skip;
                end either;"""))),
        )
Exemplo n.º 2
0
    def test_if_else(self) -> None:
        builder = IfBuilder("foo", ).then(Skip(), ).else_(Skip(), )

        assert_that(
            str(builder),
            is_(
                equal_to(
                    dedent("""\
                if foo then
                  skip;
                else
                  skip;
                end if;"""))),
        )
Exemplo n.º 3
0
    def test_with(self) -> None:
        builder = WithBuilder(
            "foo",
        ).do(
            Skip(),
            Skip(),
        )

        assert_that(
            str(builder),
            is_(equal_to(dedent("""\
                with foo
                do
                  skip;
                  skip;
                end with;"""))),
        )
Exemplo n.º 4
0
    def test_with_variables(self) -> None:
        builder = WithBuilder(
            VariableBuilder("foo"),
            VariableBuilder("bar").in_("baz"),
        ).do(
            Skip(),
            Skip(),
        )

        assert_that(
            str(builder),
            is_(equal_to(dedent("""\
                with foo, bar \\in baz
                do
                  skip;
                  skip;
                end with;"""))),
        )
Exemplo n.º 5
0
def test_macro() -> None:
    builder = MacroBuilder("foo").args("bar", ).do(Skip(), )

    assert_that(
        str(builder),
        is_(
            equal_to(
                dedent("""\
        macro foo(bar)
        begin
          skip;
        end macro;"""))))
Exemplo n.º 6
0
    def test_while(self) -> None:
        builder = WhileBuilder("TRUE", ).do(Skip(), )

        assert_that(
            str(builder),
            is_(
                equal_to(
                    dedent("""\
                while TRUE do
                  skip;
                end while;"""))),
        )
Exemplo n.º 7
0
def test_macros() -> None:
    builder = MacrosBuilder().define(MacroBuilder("foo").do(Skip()), )

    assert_that(
        str(builder),
        is_(
            equal_to(
                dedent("""\

        macro foo()
        begin
          skip;
        end macro;"""))))
Exemplo n.º 8
0
def test_processes_builder():
    builder = ProcessesBuilder().do(
        ProcessBuilder("foo", DeclType.EQUALS, "foo").do(
            Skip(),
        ),
        ProcessBuilder("bar", DeclType.EQUALS, "bar").do(
            Skip(),
        ),
    )

    assert_that(
        str(builder),
        is_(equal_to(dedent("""\

            process foo = foo
            begin
              skip;
            end process;

            process bar = bar
            begin
              skip;
            end process;"""))),
    )
Exemplo n.º 9
0
def test_process_builder():
    builder = ProcessBuilder("foo", DeclType.EQUALS, "bar").declare(
        VariableBuilder("baz"),
    ).do(
        Skip(),
    )

    assert_that(
        str(builder),
        is_(equal_to(dedent("""\
            process foo = bar
            variable baz;
            begin
              skip;
            end process;"""))),
    )
Exemplo n.º 10
0
def test_procedures() -> None:
    builder = ProceduresBuilder().define(
        ProcedureBuilder("foo").do(
            Skip(),
        ),
    )

    assert_that(
        str(builder),
        is_(equal_to(dedent("""\

        procedure foo()
        begin
          skip;
        end procedure;""")))
    )
Exemplo n.º 11
0
def test_procedure() -> None:
    builder = ProcedureBuilder("foo").args(
        "bar",
    ).vars(
        PVariableBuilder("baz", "qox"),
    ).do(
        Skip(),
    )

    assert_that(
        str(builder),
        is_(equal_to(dedent("""\
        procedure foo(bar)
        variable baz = qox;
        begin
          skip;
        end procedure;""")))
    )