def test_get_array_bound_error(): '''Test that the _get_array_bound() utility function raises the expected exception if the shape of the array's symbol is not supported.''' array_type = ArrayType(REAL_TYPE, [10]) array_symbol = DataSymbol("x", array_type) reference = Reference(array_symbol) array_type._shape = [0.2] with pytest.raises(TransformationError) as excinfo: _get_array_bound(reference, 0) assert ("Transformation Error: Unsupported index type 'float' found for " "dimension 1 of array 'x'." in str(excinfo.value))
def test_arraytype_str_invalid(): '''Test that the ArrayType class str method raises an exception if an unsupported dimension type is found. ''' scalar_type = ScalarType(ScalarType.Intrinsic.INTEGER, 4) array_type = ArrayType(scalar_type, [10]) # Make one of the array dimensions an unsupported type array_type._shape = [None] with pytest.raises(InternalError) as excinfo: _ = str(array_type) assert ("PSyclone internal error: ArrayType shape list elements can only " "be 'DataNode', or 'ArrayType.Extent', but found 'NoneType'." in str(excinfo.value))