Skip to content

Commit

Permalink
Adds unittest for Error message for dummy procedure argument. #200
Browse files Browse the repository at this point in the history
TODO: probably the workspace/symbol test will need to be moved into
a separate directory because it has to be edited every time a new test
is being added
  • Loading branch information
gnikit committed Dec 12, 2021
1 parent 355f11d commit 5650b09
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def check_return(result_array):
["test_gen_type", 5, 1],
["test_generic", 2, 0],
["test_inherit", 2, 0],
["test_int", 2, 0],
["test_mod", 2, 0],
["test_program", 2, 0],
["test_rename_sub", 6, 9],
Expand Down Expand Up @@ -596,6 +597,39 @@ def hover_request(file_path, line, char):
check_return(results[10], ((3, " !! Doc 9"), (4, " !! Doc 10")))


def test_diagnostic_interfaces():
"""
Tests the diagnostics for subroutines and functions with interfaces
as arguments
"""
string = write_rpc_request(1, "initialize", {"rootPath": test_dir})
file_path = os.path.join(test_dir, "test_diagnostic_int.f90")
string += write_rpc_notification(
"textDocument/didOpen", {"textDocument": {"uri": file_path}}
)
# Example of a diagnostics message
# string += write_rpc_notification(
# "textDocument/publishDiagnostics",
# {
# "uri": file_path,
# "diagnostics": [
# {
# "range": {
# "start": {"line": 0, "character": 0},
# "end": {"line": 0, "character": 0},
# },
# "message": "",
# "severity": 0,
# }
# ],
# },
# )
errcode, results = run_request(string)
assert errcode == 0
# check that the diagnostics list is empty
assert not results[1]['diagnostics']


if __name__ == "__main__":
test_init()
test_open()
Expand All @@ -608,3 +642,4 @@ def hover_request(file_path, line, char):
test_refs()
test_hover()
test_docs()
test_diagnostic_interfaces()
43 changes: 43 additions & 0 deletions test/test_source/test_diagnostic_int.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module test_int

implicit none

contains

subroutine foo(f, arg2)
interface
function f(x)
real, intent(in) :: x
real :: f
end function
end interface
integer, intent(in) :: arg2
real :: y
y = 1.
print*, f(y)
end subroutine foo

function foo2(f, g, h) result(arg3)
interface
function f(x) result(z)
real, intent(in) :: x
real :: z
end function
function g(x) result(z)
real, intent(in) :: x
real :: z
end function
end interface
interface
function h(x) result(z)
real, intent(in) :: x
real :: z
end function h
end interface
real :: y
real :: arg3
y = 1.
arg3 = f(g(h(y)))
end function foo2

end module test_int

0 comments on commit 5650b09

Please sign in to comment.