Beispiel #1
0
import pytest
import astpretty
import typing as typ
import DevAuto as DA
import DevAuto.Core as core
from DevAuto.Core import DStr
import DevAuto.Translator.translator as trans
from DevAuto import DFunc
from DevAuto.lang_imp import InstGrp
from TestCases.CoreTestCases.devCore_Check import BoxMachine


boxOpSpec = [
    # is_open
    core.OpSpec("is_open", [], ("successed", core.DBool)),
    # op
    core.OpSpec("op", [("arg", core.DStr)], ("ret", core.DNone)),
    # query
    core.OpSpec("query", [("arg", core.DStr)], ("ret", core.DStr))
]


class BoxMachinePlus(BoxMachine, core.Dut):

    def __init__(self) -> None:
        BoxMachine.__init__(self)
        self._operations = self._operations + boxOpSpec
        self.value = 0

    @core.Machine.operation("is_open", boxOpSpec)
    def is_open(self) -> core.DBool:
Beispiel #2
0
def spec3() -> core.OpSpec:
    return core.OpSpec("SP3", [("A3", core.DInt), ("A4", core.DStr)],
                       ("R", core.DStr))
Beispiel #3
0
def spec2() -> core.OpSpec:
    return core.OpSpec("SP2", [("A1", core.DStr), ("A2", core.DStr)],
                       ("R", core.DStr))
Beispiel #4
0
def spec1() -> core.OpSpec:
    return core.OpSpec("SP1", [("A1", core.DInt), ("A2", core.DStr)],
                       ("R", core.DStr))
Beispiel #5
0
            port = ListProperty[idx]
            DictProperty[port] = alterTo[idx]
        for idx in range(2):
            port = ListProperty[idx]
            assert alterTo[idx] == DictProperty[port]


###############################################################################
#                              Machine TestCases                              #
###############################################################################
# Box Properties
boxProperties = [core.Property("contain", ["10"])]

boxOpSpec = [
    # Open
    core.OpSpec("open", [], ("N/A", core.DType)),
    # Close
    core.OpSpec("close", [], ("N/A", core.DNone)),
    # Put
    core.OpSpec("put", [("Candy", core.DStr)], ("N/A", core.DNone)),
    # Get
    core.OpSpec("get", [], ("Candy", core.DStr))
]


class BoxMachine(core.Machine):
    """
    A machine that can open and close, just like a box.
    """
    def __init__(self) -> None:
        core.Machine.__init__(self, "Box", boxProperties, boxOpSpec)
Beispiel #6
0
    """
    A machine without properties, operations, it's trivial.
    """
    def __init__(self) -> None:
        core.Machine.__init__(self, "Trivial", [], [])


###############################################################################
#                  BoxMachine, a machine that simulate a box                  #
###############################################################################
# Box Properties
boxProperties = [core.Property("contain", 10)]

boxOpSpec = [
    # Open
    core.OpSpec("open", (), ("N/A", da_typ.DNone)),
    # Close
    core.OpSpec("close", (), ("N/A", da_typ.DNone)),
    # Put
    core.OpSpec("put", (("Candy", da_typ.DSTR)), ("N/A", da_typ.DNone)),
    # Get
    core.OpSpec("get", (), ("Candy", da_typ.DSTR))
]


class BoxMachine(core.Machine):
    """
    A machine that can open and close, just like a box.
    """
    def __init__(self) -> None:
        core.Machine.__init__(self, "Box", boxProperties, boxOpSpec)