Skip to content

Commit

Permalink
#2238 Fix typos and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sergisiso committed Aug 21, 2023
1 parent 25ce611 commit 609d154
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/psyclone/line_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def length(self):
def process(self, fortran_in):
''' Processes unlimited line-length Fortran code into Fortran
code with long lines wrapped appropriately.
:param str fortran_in: Fortran code to be line wrapped.
:returns: line wrapped Fortran code.
Expand Down
7 changes: 5 additions & 2 deletions src/psyclone/psyir/frontend/fparser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ def _find_or_create_psyclone_internal_cmp(node):
return symbol

raise NotImplementedError(
"Could not find the generic comparison interface nor an ancestor "
"container on which to add it.")
"Could not find the generic comparison interface and the scope does "
"not have an ancestor container in which to add it.")


def _check_args(array, dim):
Expand Down Expand Up @@ -3418,6 +3418,9 @@ def _process_case_value(self, selector, node, parent):
self.process_nodes(parent=fake_parent, nodes=[node])

for operand in fake_parent.lhs, fake_parent.rhs:
# If any of the operands has a datatype we can distinguish
# between boolean (which in Fortran and PSyIR uses the EQV
# operator) or not-boolean (which uses the EQ operator)
if (hasattr(operand, "datatype") and
isinstance(operand.datatype, ScalarType)):
if (operand.datatype.intrinsic ==
Expand Down
24 changes: 12 additions & 12 deletions src/psyclone/tests/psyir/frontend/fparser2_select_case_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,9 @@ def test_find_or_create_psyclone_internal_cmp(fortran_writer):
# If it is not inside a Container it producess a NotImplementedError
with pytest.raises(NotImplementedError) as error:
_ = _find_or_create_psyclone_internal_cmp(node_in_subroutine)
assert ("Could not find the generic comparison interface nor an ancestor "
"container on which to add it." in str(error.value))
assert ("Could not find the generic comparison interface and the scope "
"does not have an ancestor container in which to add it."
in str(error.value))

container = Container("test", children=[subroutine])
symbol = _find_or_create_psyclone_internal_cmp(node_in_subroutine)
Expand All @@ -518,12 +519,12 @@ def test_find_or_create_psyclone_internal_cmp(fortran_writer):
"psyclone_internal_cmp")
assert symbol.visibility == Symbol.Visibility.PRIVATE
assert len(container.children) == 4
assert container.symbol_table.lookup("psyclone_cmp_int").visibility \
== Symbol.Visibility.PRIVATE
assert container.symbol_table.lookup("psyclone_cmp_logical").visibility \
== Symbol.Visibility.PRIVATE
assert container.symbol_table.lookup("psyclone_cmp_char").visibility \
== Symbol.Visibility.PRIVATE
assert (container.symbol_table.lookup("psyclone_cmp_int").visibility
== Symbol.Visibility.PRIVATE)
assert (container.symbol_table.lookup("psyclone_cmp_logical").visibility
== Symbol.Visibility.PRIVATE)
assert (container.symbol_table.lookup("psyclone_cmp_char").visibility
== Symbol.Visibility.PRIVATE)

# Check the generated code matches the expected code
has_cmp_interface(fortran_writer(container))
Expand Down Expand Up @@ -551,7 +552,7 @@ def test_find_or_create_psyclone_internal_cmp(fortran_writer):
procedure psyclone_cmp_char_1
end interface psyclone_internal_cmp_1''' in fortran_writer(container)

# And that from now on the tag referes to the new symbol
# And that from now on the tag refers to the new symbol
assert container.symbol_table.lookup_with_tag(
"psyclone_internal_cmp").name == "psyclone_internal_cmp_1"

Expand Down Expand Up @@ -616,7 +617,7 @@ def test_unknown_types_case(fortran_reader, fortran_writer):
# Check that the interface implementation has been inserted
has_cmp_interface(output)

# Check that the cannonicalised comparisons use the interface method
# Check that the canonicalised comparisons use the interface method
assert "if (psyclone_internal_cmp(a, b)) then" in output
assert "if (psyclone_internal_cmp(a, c)) then" in output

Expand Down Expand Up @@ -668,7 +669,6 @@ def test_derived_types_case(fortran_reader, fortran_writer):
assert "if (a%field == 1) then" in output
assert "if (a%field == 2) then" in output


# And then the datatype information is unknown
code = '''
module test
Expand All @@ -692,6 +692,6 @@ def test_derived_types_case(fortran_reader, fortran_writer):
# Check that the interface implementation has been inserted
has_cmp_interface(output)

# Check that the cannonicalised comparisons use the interface method
# Check that the canonicalised comparisons use the interface method
assert "if (psyclone_internal_cmp(a%b(i)%c, b%d)) then" in output
assert "if (psyclone_internal_cmp(a%b(i)%c, c%a)) then" in output

0 comments on commit 609d154

Please sign in to comment.