Skip to content

Commit 0b09133

Browse files
committed
Move hover unittests to separate file
1 parent c6ad8c0 commit 0b09133

File tree

2 files changed

+321
-135
lines changed

2 files changed

+321
-135
lines changed

test/test_server.py

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -381,138 +381,3 @@ def find_in_results(uri, sline):
381381
[free_path, 78, 6, 12],
382382
),
383383
)
384-
385-
386-
def test_hover():
387-
def hover_req(file_path: str, ln: int, col: int) -> str:
388-
return write_rpc_request(
389-
1,
390-
"textDocument/hover",
391-
{
392-
"textDocument": {"uri": str(file_path)},
393-
"position": {"line": ln, "character": col},
394-
},
395-
)
396-
397-
def check_return(result_array, checks):
398-
assert len(result_array) == len(checks)
399-
for (i, check) in enumerate(checks):
400-
assert result_array[i]["contents"][0]["value"] == check
401-
402-
#
403-
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
404-
file_path = test_dir / "subdir" / "test_abstract.f90"
405-
string += hover_req(file_path, 7, 30)
406-
file_path = test_dir / "hover" / "parameters.f90"
407-
string += hover_req(file_path, 2, 28)
408-
string += hover_req(file_path, 3, 28)
409-
string += hover_req(file_path, 4, 28)
410-
string += hover_req(file_path, 4, 41)
411-
string += hover_req(file_path, 6, 28)
412-
string += hover_req(file_path, 7, 38)
413-
string += hover_req(file_path, 7, 55)
414-
string += hover_req(file_path, 8, 37)
415-
string += hover_req(file_path, 8, 50)
416-
string += hover_req(file_path, 9, 37)
417-
string += hover_req(file_path, 9, 48)
418-
string += hover_req(file_path, 10, 37)
419-
string += hover_req(file_path, 10, 48)
420-
file_path = test_dir / "hover" / "pointers.f90"
421-
string += hover_req(file_path, 1, 26)
422-
file_path = test_dir / "hover" / "functions.f90"
423-
string += hover_req(file_path, 1, 11)
424-
string += hover_req(file_path, 7, 19)
425-
string += hover_req(file_path, 12, 12)
426-
string += hover_req(file_path, 18, 19)
427-
string += hover_req(file_path, 23, 34)
428-
string += hover_req(file_path, 28, 11)
429-
string += hover_req(file_path, 34, 21)
430-
string += hover_req(file_path, 46, 11)
431-
string += hover_req(file_path, 51, 11)
432-
string += hover_req(file_path, 55, 11)
433-
file_path = test_dir / "hover" / "spaced_keywords.f90"
434-
string += hover_req(file_path, 1, 45)
435-
string += hover_req(file_path, 2, 99)
436-
file_path = test_dir / "hover" / "recursive.f90"
437-
string += hover_req(file_path, 9, 40)
438-
file_path = test_dir / "subdir" / "test_submod.F90"
439-
string += hover_req(file_path, 29, 24)
440-
string += hover_req(file_path, 34, 24)
441-
file_path = test_dir / "test_diagnostic_int.f90"
442-
string += hover_req(file_path, 19, 14)
443-
444-
errcode, results = run_request(string, fortls_args=["--sort_keywords"])
445-
assert errcode == 0
446-
#
447-
ref_results = (
448-
"""SUBROUTINE test(a, b)
449-
INTEGER(4), DIMENSION(3,6), INTENT(IN) :: a
450-
REAL(8), DIMENSION(4), INTENT(OUT) :: b""",
451-
"INTEGER, PARAMETER :: var = 1000",
452-
"INTEGER",
453-
"INTEGER, PARAMETER :: var2 = 23",
454-
"INTEGER, PARAMETER :: var3 = var*var2",
455-
"INTEGER, PARAMETER :: var4 = 123",
456-
"DOUBLE PRECISION, PARAMETER :: somevar = 23.12",
457-
"DOUBLE PRECISION, PARAMETER :: some = 1e-19",
458-
"LOGICAL(kind=8), PARAMETER :: long_bool = .true.",
459-
"LOGICAL",
460-
"CHARACTER(len=5), PARAMETER :: sq_str = '12345'",
461-
"CHARACTER(LEN=5)",
462-
'CHARACTER(len=5), PARAMETER :: dq_str = "12345"',
463-
"CHARACTER(LEN=5)",
464-
"INTEGER, POINTER",
465-
"""FUNCTION fun1(arg) RESULT(fun1)
466-
INTEGER, INTENT(IN) :: arg
467-
INTEGER :: fun1""",
468-
"""FUNCTION fun2(arg) RESULT(fun2)
469-
INTEGER, INTENT(IN) :: arg
470-
INTEGER :: fun2""",
471-
"""FUNCTION fun3(arg) RESULT(retval)
472-
INTEGER, INTENT(IN) :: arg
473-
INTEGER :: retval""",
474-
"""FUNCTION fun4(arg) RESULT(retval)
475-
INTEGER, INTENT(IN) :: arg
476-
INTEGER :: retval""",
477-
# Notice that the order of the modifiers does not match the source code
478-
# This is part of the test, ideally they would be identical but previously
479-
# any modifiers before the type would be discarded
480-
"""PURE ELEMENTAL FUNCTION fun5(arg) RESULT(retval)
481-
INTEGER, INTENT(IN) :: arg
482-
INTEGER :: retval""",
483-
"""FUNCTION fun6(arg) RESULT(retval)
484-
INTEGER, INTENT(IN) :: arg
485-
INTEGER, DIMENSION(10,10) :: retval""",
486-
"""PURE FUNCTION outer_product(x, y) RESULT(outer_product)
487-
REAL, DIMENSION(:), INTENT(IN) :: x
488-
REAL, DIMENSION(:), INTENT(IN) :: y
489-
REAL, DIMENSION(SIZE(X), SIZE(Y)) :: outer_product""",
490-
"""FUNCTION dlamch(cmach) RESULT(dlamch)
491-
CHARACTER :: CMACH""",
492-
"""FUNCTION fun7() RESULT(val)
493-
TYPE(c_ptr) :: val""",
494-
"""TYPE(c_ptr) FUNCTION c_loc(x) RESULT(c_loc)""",
495-
"""REAL, DIMENSION(:, :), INTENT(IN)""",
496-
"""REAL, DIMENSION( SIZE(ARG1, 1), MAXVAL([SIZE(ARG1, 2), """
497-
"""SIZE(ARG1, 1)]) ), INTENT(OUT)""",
498-
"""RECURSIVE SUBROUTINE recursive_assign_descending(node, vector, current_loc)
499-
TYPE(tree_inode), POINTER, INTENT(IN) :: node
500-
INTEGER, DIMENSION(:), INTENT(INOUT) :: vector
501-
INTEGER, INTENT(INOUT) :: current_loc""",
502-
"""FUNCTION point_dist(a, b) RESULT(distance)
503-
TYPE(point), INTENT(IN) :: a
504-
TYPE(point), INTENT(IN) :: b
505-
REAL :: distance""",
506-
"""FUNCTION is_point_equal_a(a, b) RESULT(is_point_equal_a)
507-
TYPE(point), INTENT(IN) :: a
508-
TYPE(point), INTENT(IN) :: b
509-
LOGICAL :: is_point_equal_a""",
510-
# Could be subject to change
511-
"""FUNCTION foo2(f, g, h) RESULT(arg3)
512-
FUNCTION f(x) :: f
513-
FUNCTION g(x) :: g
514-
FUNCTION h(x) :: h
515-
REAL :: arg3""",
516-
)
517-
assert len(ref_results) == len(results) - 1
518-
check_return(results[1:], ref_results)

0 commit comments

Comments
 (0)