Esempio n. 1
0
def test_gokerneltype_argname():
    '''Test that a GOcean kerneltype class raises an appropriate exception
    if the meta_arg name is not 'arg'.

    '''
    my_code = CODE.replace("arg(", "invalid(")
    parse_tree = parse1(my_code)
    with pytest.raises(ParseError) as excinfo:
        _ = GOKernelType(parse_tree)
    assert ("Each meta_arg value must be of type 'arg' for the gocean0.1 "
            "api, but found 'invalid'.") in str(excinfo.value)
Esempio n. 2
0
def test_gokerneltype_nargs():
    '''Test that a GOcean kerneltype class raises an appropriate exception
    if a meta_arg has more than 3 entries.

    '''
    my_code = CODE.replace("E)", "E, INVALID)")
    parse_tree = parse1(my_code)
    with pytest.raises(ParseError) as excinfo:
        _ = GOKernelType(parse_tree)
    assert "'arg' type expects 3 arguments but found 4" \
        in str(excinfo.value)
Esempio n. 3
0
def test_dynkerneltype_argtype():
    '''Test that a dynamo0.1 api-specific DynKernelType class raises an
    exception if the meta_arg value is not named 'arg_type'.

    '''

    my_code = CODE.replace("arg_type(", "invalid(")
    parse_tree = parse1(my_code)
    with pytest.raises(ParseError) as excinfo:
        _ = DynKernelType(parse_tree)
    assert ("Each meta_arg value must be of type 'arg_type' for the "
            "dynamo0.1 api, but found 'invalid'.") in str(excinfo.value)
Esempio n. 4
0
def test_gokerneltype():
    '''Test that a GOcean kerneltype class can be created
    succesfully.

    '''
    my_code = CODE
    parse_tree = parse1(my_code)
    tmp = GOKernelType(parse_tree)
    assert tmp.iterates_over == "dofs"
    assert tmp.nargs == 1
    assert tmp.name == "test_type"
    descriptor = tmp.arg_descriptors[0]
    assert descriptor.access == AccessType.READ
    assert descriptor.function_space == "every"
    assert descriptor.stencil == "pointwise"
Esempio n. 5
0
def test_dynkerneltype():
    '''Test that a dynamo0.1 api-specific DynKernelType class can be
    created successfully.

    '''
    parse_tree = parse1(CODE)
    tmp = DynKernelType(parse_tree)
    assert tmp.name == "testkern_type"
    assert tmp.iterates_over == "cells"
    assert tmp.nargs == 1
    descriptor = tmp.arg_descriptors[0]
    assert descriptor.access == "gh_rw"
    assert descriptor.function_space == "v1"
    assert descriptor.stencil == "fe"
    assert descriptor.basis == ".false."
    assert descriptor.diff_basis == ".false."
    assert descriptor.gauss_quad == ".false."