Example #1
0
 def check_type(t):
     type_name_check = get_model(t)._tx_model_params.get('type_name_check',
                                                         default='on')
     assert type_name_check in ['on', 'off']
     if type_name_check == 'on':
         if t.name[0].isupper():
             raise TextXSyntaxError("types must be lowercase",
                                    **tools.get_location(t))
Example #2
0
def check_testcase(testcase):
    """
    checks that the config used by the testcase fulfills its needs
    """
    for need in testcase.needs:
        if need not in testcase.config.haves:
            raise TextXSemanticError(
                "{}: {} not found in {}.{}".format(testcase.name, need.name,
                                                   testcase.scenario.name,
                                                   testcase.config.name),
                **get_location(testcase))
Example #3
0
def check_exam(exam):
    min_dur = exam.get_points()
    if exam.duration < min_dur:
        raise exceptions.TextXSemanticError(
            'duration ({}) too short (< sumPoints {})'.format(
                exam.duration, exam.get_points()), *get_location(exam))

    max_dur = exam.get_points() * 100 / 80
    max_dur = max(max_dur, exam.get_points() + 5)
    if exam.duration > max_dur:
        raise exceptions.TextXSemanticError(
            'duration ({}) too long (> f(sumPoints) {})'.format(
                exam.duration, max_dur), *get_location(exam))

    for exercise_ref in get_children_of_type('PExerciseRef', exam):
        exercise = exercise_ref.get()
        if len(list(filter(lambda x: x == exercise,
                           exam.get_exercises()))) > 1:
            raise exceptions.TextXSemanticError(
                'exercise {} used more than once'.format(
                    exercise._tx_filename), *get_location(exercise_ref))
 def check_flow(f):
     if f.algo1.outp != f.algo2.inp:
         raise textx.exceptions.TextXSemanticError(
             "algo data types must match",
             **tools.get_location(f)
         )
 def check_type(t):
     if t.name[0].isupper():
         raise textx.exceptions.TextXSyntaxError(
             "types must be lowercase",
             **tools.get_location(t)
         )
Example #6
0
 def my_processor(m):
     from textx.exceptions import TextXSemanticError
     from textx.scoping.tools import get_location
     if m.name == "d1":
         raise TextXSemanticError("d1 triggers artifical error",
                                  **get_location(m))
 def check_type(t):
     if t.name[0].isupper():
         raise textx.exceptions.TextXSyntaxError("types must be lowercase",
                                                 **tools.get_location(t))
 def check_flow(f):
     if f.algo1.outp != f.algo2.inp:
         raise textx.exceptions.TextXSemanticError(
             "algo data types must match", **tools.get_location(f))
 def my_processor(m):
     from textx.exceptions import TextXSemanticError
     from textx.scoping.tools import get_location
     if m.name == "d1":
         raise TextXSemanticError("d1 triggers artifical error",
                                  **get_location(m))