Пример #1
0
        ClassExpression(
            'CLASS(0, 0, 1, 0) * CLASS(0, 0, 1, 0) == INSTANCE'
        ),
        ClassExpression(
            'CLASS(0, 0, 0, 1) * CLASS(0, 0, 0, 1) == INSTANCE'
        ),
        ClassExpression(
            'CLASS(0, 1, 0, 0) * CLASS(0, 0, 1, 0) == CLASS(0, 0, 0, 1)'
        ),
        ClassExpression(
            'CLASS(0, 0, 1, 0) * CLASS(0, 0, 0, 1) == CLASS(0, 1, 0, 0)'
        ),
        ClassExpression(
            'CLASS(0, 0, 0, 1) * CLASS(0, 1, 0, 0) == CLASS(0, 0, 1, 0)'
        ),
    ),
    ClassScenario(
        Args(0, 1, 0, 0),
        ClassExpression(
            'CLASS(0, 1, 0, 0) * CLASS(0, 0, 1, 0) == -1'
        ),
    ),
]

exo_quaternion = ExerciseClass(
    Quaternion, quaternion_scenarios,
    nb_examples=0,
    obj_name='Q',
    header_font_size='small',
)
Пример #2
0
        Args(kelvin=0),
        ClassExpression("INSTANCE.kelvin"),
        ClassExpression("INSTANCE.celsius"),
    ),
    ClassScenario(
        Args(celsius=0),
        ClassExpression("INSTANCE.kelvin"),
        ClassExpression("INSTANCE.celsius"),
    ),
    ClassScenario(
        Args(kelvin=0),
        ClassExpression("INSTANCE.kelvin"),
        ClassExpression("INSTANCE.celsius"),
    ),
]

exo_temperature = ExerciseClass(
    Temperature,
    temperature_scenarios,
    nb_examples=0,
    obj_name='temp',
)


class Temperature_ko:
    def __init__(self, **kwds):
        self._kelvin = 200

    def __repr__(self):
        return f"{self._kelvin:2f}°"
Пример #3
0
MMXXI=2021
MMXXII=2022
MMXXIII=2023
MMXXIV=2024
MMXXV=2025
MMXXVI=2026
MMXXVII=2027
MMXXVIII=2028
"""

for line in raw.split():
    letters, number = line.split('=')
    roman_scenarios.append(
        ClassScenario(
            Args(letters),
            ClassExpression(f"INSTANCE == CLASS({number})"),
        ))
    roman_scenarios.append(
        ClassScenario(
            Args(number),
            ClassExpression(f"INSTANCE == CLASS('{letters}')"),
        ))

exo_roman = ExerciseClass(
    Roman,
    roman_scenarios,
    nb_examples=0,
    obj_name='R',
    header_font_size='small',
)
Пример #4
0
    ),
    ClassScenario(
        Args(1, 2, 3),
        ClassExpression("INSTANCE + CLASS(1, 2, 3, 4) == CLASS(1, 3, 5, 7)"),
        ClassExpression("INSTANCE + CLASS(4, 3, 2, 1) == CLASS(4, 4, 4, 4)"),
    ),
    # (3x2 + 2x + 1) * (x+2) = 3x3 + 8x2 + 5x + 2
    ClassScenario(
        Args(3, 2, 1),
        ClassExpression("INSTANCE * CLASS() == CLASS()"),
        ClassExpression("INSTANCE * CLASS(1) == INSTANCE"),
        ClassExpression("INSTANCE * CLASS(1, 2) == CLASS(3, 8, 5, 2)"),
    ),
]

exo_polynomial = ExerciseClass(
    Polynomial, polynomial_scenarios,
    nb_examples=0,
    obj_name='P',
    header_font_size='small',
)


class Polynomial_ko:

    def __init__(self, *args):
        self.coefs = args[::-1]

    def repr(self):
        return " + ".join(f"{c}X{d}" for c, d in zip(self.coefs, count()))
Пример #5
0
#        "INSTANCE",
        "INSTANCE.outgoing()",
        "INSTANCE.incoming(3)",
#        "INSTANCE",
        "INSTANCE.outgoing()",
#        "INSTANCE",
        "INSTANCE.outgoing()",
        "INSTANCE.outgoing()",
    ),

    ClassScenario(
        # init arguments
        Args(),
        "INSTANCE.incoming(1)",
        "INSTANCE.incoming(2)",
        "INSTANCE.outgoing()",
        "INSTANCE.outgoing()",
        "INSTANCE.incoming(3)",
        "INSTANCE.incoming(4)",
        "INSTANCE.outgoing()",
        "INSTANCE.outgoing()",
    ),

]

exo_fifo = ExerciseClass(
    Fifo, fifo_scenarios,
    obj_name = "F",
    check_init=False,
)
Пример #6
0
        Args(),
        ClassExpression("INSTANCE.foo"),
    ),
    ClassScenario(
        Args(),
        ClassExpression("INSTANCE.Foo_Bar"),
    ),
]

for r in range(3, 6):
    redirector1_scenarios.append(
        ClassScenario(Args(), ClassExpression(f"INSTANCE.{random_name()}")))

exo_redirector1 = ExerciseClass(
    Redirector1,
    redirector1_scenarios,
    nb_examples=2,
    obj_name='R',
)


class Redirector1_ko:
    def __init__(self):
        self.foo = 'foo'
        self.Foo_Bar = 'foo-bar'

    def __repr__(self):
        return "redirector"


# @BEG@ name=redirector2
class Redirector2: