Skip to content

Commit 4a94a66

Browse files
committed
add test for goto (definition/declaration) parts
1 parent 01541ac commit 4a94a66

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

tests/robotcode/language_server/common/test_window.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
results
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
*** Settings ***
2+
Library Collections
3+
# ^^^^^^^^^^^ Robot Library Import: len(result) == 1 and result[0].target_uri.endswith("robot/libraries/Collections.py")
4+
# ^^^^^^^^^^^ Separator: result is None or len(result) == 0
5+
Library ${CURDIR}/libs/myvariables.py
6+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Library Import by Path: len(result) == 1 and result[0].target_uri.endswith("/libs/myvariables.py")
7+
Variables ${CURDIR}/libs/myvariables.py
8+
# TODO ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Variables Import: len(result) == 1 and result[0].target_uri.endswith("libs/myvariables.py")
9+
Resource ${CURDIR}/resources/firstresource.resource
10+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Resource Import: len(result) == 1 and result[0].target_uri.endswith("/resources/firstresource.resource")
11+
12+
*** Variables ***
13+
${A VAR} i'm a var
14+
&{A DICT} a=1 b=2 c=3
15+
16+
*** Test Cases ***
17+
first
18+
Log Hello ${A VAR}
19+
# ^^^^^^^ Variable: len(result) == 1 and result[0].target_uri.endswith("/data/goto.robot")
20+
# ^^^ BuiltIn Keyword: len(result) == 1 and result[0].target_uri.endswith("robot/libraries/BuiltIn.py")
21+
Collections.Log Dictionary ${A DICT}
22+
# ^^^^^^^^^ Variable: len(result) == 1 and result[0].target_uri.endswith("/data/goto.robot")
23+
# ^^^^^^^^^^^^^^ Robot Library Keyword: len(result) == 1 and result[0].target_uri.endswith("robot/libraries/Collections.py")
24+
FOR ${key} ${value} IN &{A DICT}
25+
Log ${key}=${value}
26+
# ^^^^^^ For Variable: len(result) == 1 and result[0].target_uri.endswith("/data/goto.robot")
27+
# ^^^^^^^^ For Variable: len(result) == 1 and result[0].target_uri.endswith("/data/goto.robot")
28+
END
29+
Log ${CMD_VAR}
30+
# TODO ^^^^^^^^^^ Command Line Variable: len(result) == 1 and result[0].target_uri.endswith("...")
31+
Log ${CURDIR}
32+
# TODO ^^^^^^^^^ BuiltIn Variable: len(result) == 1 and result[0].target_uri.endswith("...")
33+
Log ${A_VAR_FROM_LIB}
34+
# TODO ^^^^^^^^^^^^^^^^^ Imported Variable: len(result) == 1 and result[0].target_uri.endswith("...")

tests/robotcode/language_server/robotframework/parts/data/hover.robot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ first
3535
#^^^ Spaces: result is None
3636
Log ${A_VAR_FROM_LIB}
3737
# TODO ^^^^^^^^^^^^^^^^^ BuiltIn variable: value == '(imported variable) ${A_VAR_FROM_LIB}'
38-
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import re
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
from robotcode.language_server.common.text_document import TextDocument
7+
from robotcode.language_server.common.types import Position
8+
from robotcode.language_server.robotframework.protocol import (
9+
RobotLanguageServerProtocol,
10+
)
11+
12+
from ..tools import generate_tests_from_source_document
13+
14+
15+
@pytest.mark.parametrize(
16+
("test_document", "name", "line", "character", "expression"),
17+
generate_tests_from_source_document(str(Path(Path(__file__).parent, "data/goto.robot"))),
18+
indirect=["test_document"],
19+
)
20+
@pytest.mark.asyncio
21+
@pytest.mark.usefixtures("protocol")
22+
async def test_goto(
23+
protocol: RobotLanguageServerProtocol,
24+
test_document: TextDocument,
25+
name: str,
26+
line: int,
27+
character: int,
28+
expression: str,
29+
) -> None:
30+
result = await protocol._robot_goto.collect(
31+
protocol._robot_goto, test_document, Position(line=line, character=character)
32+
)
33+
34+
assert bool(
35+
eval(
36+
expression,
37+
{"re": re},
38+
{
39+
"result": result,
40+
"line": line,
41+
"character": character,
42+
},
43+
)
44+
), f"{expression} {repr(result)}"

0 commit comments

Comments
 (0)