# loki.expression.tests.test_expression

Functions

`test_arithmetic`(tmp_path, frontend) | Test simple floating point arithmetic expressions (+,-,*,/,**).
`test_array_constructor`(tmp_path, frontend) | Test various array constructor formats
`test_array_to_inline_call_rescope`(parse) | Test a mechanism that can convert arrays to procedure calls, to mop up broken frontend behaviour wrongly classifying inline calls as array subscripts
`test_boz_literals`(tmp_path, frontend) | Test boz literal values.
`test_casts`(tmp_path, frontend) | Test data type casting expressions.
`test_character_concat`(tmp_path, frontend) | Concatenation operator `//`
`test_commutativity`(frontend) | Verifies the strict adherence to ordering of commutative terms, which can introduce round-off errors if not done conservatively.
`test_complex_literals`(tmp_path, frontend) | Test complex literal values.
`test_expression_c_de_reference`(frontend) | Verify that ``Reference` and `Dereference` work as expected.
`test_expression_container_matching`() | Tests how different expression types match as keys in different containers, with use of raw expressions and string equivalence.
`test_general_intrinsics`(frontend) | Test general intrinsic functions (size, shape, ubound, lbound, allocated, trim, kind)
`test_index_ranges`(frontend) | Test index range expressions for array accesses.
`test_inline_call_derived_type_arguments`(...) | Check that derived type arguments are correctly represented in function calls that include keyword parameters.
`test_kwargs_inline_call`(frontend, tmp_path) | Test inline call with kwargs and correct sorting as well as correct conversion to args.
`test_literals`(tmp_path, frontend) | Test simple literal values.
`test_logical_array`(tmp_path, frontend) | Test logical arrays for masking.
`test_logicals`(tmp_path, frontend) | Test logical expressions (and, or, not, tru, false, equal, not nequal).
`test_masked_statements`(tmp_path, frontend) | Masked statements (WHERE(...) .
`test_masked_statements_nested`(tmp_path, frontend) | Nested masked statements (WHERE(...) .
`test_math_intrinsics`(tmp_path, frontend) | Test supported math intrinsic functions (min, max, exp, abs, sqrt, log)
`test_nested_call_inline_call`(tmp_path, frontend) | The purpose of this test is to highlight the differences between calls in expression (such as InlineCall, Cast) and call nodes in the IR.
`test_nested_derived_type_substitution`() | Test that `SubstituteExpressions` can properly replace scalar parents when type is not changed
`test_no_arg_inline_call`(frontend, tmp_path) | Make sure that no-argument function calls are recognized as such, especially when their implementation is unknown.
`test_output_intrinsics`(frontend) | Some collected intrinsics or other edge cases that failed in cloudsc.
`test_parameter_stmt`(tmp_path, frontend) | PARAMETER(...) statement
`test_parenthesis`(frontend) | Test explicit parenthesis in provided source code.
`test_pointer_nullify`(tmp_path, frontend) | POINTERS and their nullification via '=> NULL()'
`test_recursive_substitution`(frontend) | Test expression substitution where the substitution key is included in the replacement
`test_standalone_expr_parenthesis`(expr, parse) |
`test_stmt_func_heuristic`(frontend, tmp_path) | Our Fparser translation has a heuristic to detect statement function declarations, but that falsely misinterpreted some assignments as statement functions due to missing shape information (reported in #326)
`test_string_compare`() | Test that we can identify symbols and expressions by equivalent strings.
`test_strings`(tmp_path, frontend, capsys) | Test recognition of literal strings.
`test_subexpression_match`(parse, expr, ...) | Test that we can identify individual symbols or sub-expressions in expressions via canonical string matching.
`test_typebound_resolution`(expr) | Test that type-bound variables can be correctly resolved
`test_typebound_resolution_type_info`(...) |
`test_variable_clone_class`(initype, ...) | Test that cloning a variable object changes class according to symbol type
`test_variable_clone_type`(initype, newtype, ...) | Test type updates are handled as expected and types are never `None`.
`test_variable_factory`(kwargs, reftype) | Test the factory class `Variable` and the dispatch to correct classes.
`test_variable_factory_invalid`() | Test invalid variable instantiations
`test_variable_in_declaration_initializer`(...) | Check correct handling of cases where the variable appears in the initializer expression (i.e. no infinite recursion).
`test_variable_in_dimensions`(frontend, tmp_path) | Check correct handling of cases where the variable appears in the dimensions expression of the same variable (i.e. do not cause infinite recursion).
`test_variable_rebuild`(initype, inireftype, ...) | Test that rebuilding a variable object changes class according to symmbol type
`test_variable_without_scope`() | Test that creating variables without scope works and scopes can be attached and detached
`test_very_long_statement`(tmp_path, frontend) | Test a long statement with line breaks.

test_arithmetic(tmp_path, frontend)

  Test simple floating point arithmetic expressions (+,-,*,/,**).

test_math_intrinsics(tmp_path, frontend)

  Test supported math intrinsic functions (min, max, exp, abs, sqrt, log)

test_general_intrinsics(frontend)

  Test general intrinsic functions (size, shape, ubound, lbound, allocated, trim, kind)

test_logicals(tmp_path, frontend)

  Test logical expressions (and, or, not, tru, false, equal, not nequal).

test_literals(tmp_path, frontend)

  Test simple literal values.

test_boz_literals(tmp_path, frontend)

  Test boz literal values.

test_complex_literals(tmp_path, frontend)

  Test complex literal values.

test_casts(tmp_path, frontend)

  Test data type casting expressions.

test_logical_array(tmp_path, frontend)

  Test logical arrays for masking.

test_array_constructor(tmp_path, frontend)

  Test various array constructor formats

test_parenthesis(frontend)

  Test explicit parenthesis in provided source code.

  Note, that this test is very niche, as it ensures that mathematically insignificant (and hence sort of wrong) bracketing is still honoured. The reason is that, if sub-expressions are sufficiently complex, this can still cause round-off deviations and hence destroy bit-reproducibility.

  Also note, that the OMNI-frontend parser will resolve precedence and hence we cannot honour these precedence cases (for now).

test_commutativity(frontend)

  Verifies the strict adherence to ordering of commutative terms, which can introduce round-off errors if not done conservatively.

test_index_ranges(frontend)

  Test index range expressions for array accesses.

test_strings(tmp_path, frontend, capsys)

  Test recognition of literal strings.

test_very_long_statement(tmp_path, frontend)

  Test a long statement with line breaks.

test_output_intrinsics(frontend)

  Some collected intrinsics or other edge cases that failed in cloudsc.

test_nested_call_inline_call(tmp_path, frontend)

  The purpose of this test is to highlight the differences between calls in expression (such as InlineCall, Cast) and call nodes in the IR.

test_no_arg_inline_call(frontend, tmp_path)

  Make sure that no-argument function calls are recognized as such, especially when their implementation is unknown.

test_kwargs_inline_call(frontend, tmp_path)

  Test inline call with kwargs and correct sorting as well as correct conversion to args.

test_inline_call_derived_type_arguments(frontend, tmp_path)

  Check that derived type arguments are correctly represented in function calls that include keyword parameters.

  This is due to fparser’s habit of sometimes representing function calls wrongly as structure constructors, which are handled differently in Loki’s frontend

test_character_concat(tmp_path, frontend)

  Concatenation operator `//`

test_masked_statements(tmp_path, frontend)

  Masked statements (WHERE(…) … [ELSEWHERE …] ENDWHERE)

test_masked_statements_nested(tmp_path, frontend)

  Nested masked statements (WHERE(…) … [ELSEWHERE …] ENDWHERE)

test_pointer_nullify(tmp_path, frontend)

  POINTERS and their nullification via ‘=> NULL()’

test_parameter_stmt(tmp_path, frontend)

  PARAMETER(…) statement

test_string_compare()

  Test that we can identify symbols and expressions by equivalent strings.

  Note that this only captures comparsion of a canonical string representation, not full symbolic equivalence.

test_subexpression_match(parse, expr, string, ref)

  Test that we can identify individual symbols or sub-expressions in expressions via canonical string matching.

test_variable_factory(kwargs, reftype)

  Test the factory class `Variable` and the dispatch to correct classes.

test_variable_factory_invalid()

  Test invalid variable instantiations

test_variable_rebuild(initype, inireftype, newtype, newreftype)

  Test that rebuilding a variable object changes class according to symmbol type

test_variable_clone_class(initype, inireftype, newtype, newreftype)

  Test that cloning a variable object changes class according to symbol type

test_variable_clone_type(initype, newtype, reftype)

  Test type updates are handled as expected and types are never `None`.

test_variable_without_scope()

  Test that creating variables without scope works and scopes can be attached and detached

test_standalone_expr_parenthesis(expr, parse)

test_array_to_inline_call_rescope(parse)

  Test a mechanism that can convert arrays to procedure calls, to mop up broken frontend behaviour wrongly classifying inline calls as array subscripts

test_recursive_substitution(frontend)

  Test expression substitution where the substitution key is included in the replacement

test_nested_derived_type_substitution()

  Test that `SubstituteExpressions` can properly replace scalar parents when type is not changed

test_variable_in_declaration_initializer(frontend)

  Check correct handling of cases where the variable appears in the initializer expression (i.e. no infinite recursion)

test_variable_in_dimensions(frontend, tmp_path)

  Check correct handling of cases where the variable appears in the dimensions expression of the same variable (i.e. do not cause infinite recursion)

test_expression_container_matching()

  Tests how different expression types match as keys in different containers, with use of raw expressions and string equivalence.

test_expression_c_de_reference(frontend)

  Verify that ``Reference` and `Dereference` work as expected. Thus, being ignored by Fortran-like backends but not by C-like backends.

test_typebound_resolution(expr)

  Test that type-bound variables can be correctly resolved

test_typebound_resolution_type_info(frontend, tmp_path)

test_stmt_func_heuristic(frontend, tmp_path)

  Our Fparser translation has a heuristic to detect statement function declarations, but that falsely misinterpreted some assignments as statement functions due to missing shape information (reported in #326)