Skip to content

Commit 8817da5

Browse files
Marcelo D Montulpil
authored andcommitted
Small improvements (honza#1037)
* robot: Improve the condition snippets Improved the condition snippet by providing more placeholders. Also included quotes on all the conditions, as they are necessary for string comparison and doesn't hurt on numeric comparison, as explained in http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Evaluating%20expressions * robot: break one line ifs Changed some snippets to have the condition and else/else if separated from the keyword in the body, to make the code easier to read.
1 parent 3be398c commit 8817da5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

UltiSnips/robot.snippets

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Return From Keyword ${1:${optional return value}}
2929
endsnippet
3030

3131
snippet rfki "Return From Keyword If"
32-
Return From Keyword If ${1:${condition}} ${2:${optional return value}}
32+
Return From Keyword If '\${${1:rc}}' != '${2:abc}' ${3:${optional return value}}
3333
endsnippet
3434

3535
snippet rk "Run Keyword"
@@ -54,17 +54,20 @@ Run Keyword And Return ${1:${kw}} ${2:${args}}
5454
endsnippet
5555

5656
snippet rkari "Run Keyword And Return If"
57-
Run Keyword And Return If ${1:{condition}} ${2:${kw}} ${3:${args}}
57+
Run Keyword And Return If '\${${1:rc}}' != '${2:abc}' ${3:${kw}} ${4:${args}}
5858
endsnippet
5959

6060
snippet rkars "Run Keyword And Return Status"
6161
\${${3:result}}= Run Keyword And Return Status ${1:${kw}} ${2:${args}}
6262
endsnippet
6363

6464
snippet rki "Run Keyword If"
65-
Run Keyword If ${1:${rc} < 0} ${2:${VISUAL:Some keyword returning a value}}
66-
... ELSE IF ${3:'${str}' == 'abc'} ${4:Another keyword}
67-
... ELSE ${5:Final keyword}
65+
Run Keyword If '\${${1:rc}}' != '${2:abc}'
66+
... ${3:${VISUAL:Some keyword returning a value}}
67+
... ELSE IF '\${${4:str}}' != '${5:def}'
68+
... ${6:Another keyword}
69+
... ELSE
70+
... ${7:Final keyword}
6871
endsnippet
6972

7073
snippet rkiactf "Run Keyword If Any Critical Tests Failed"
@@ -102,7 +105,7 @@ Run Keywords
102105
endsnippet
103106

104107
snippet rku "Run Keyword Unless"
105-
Run Keyword Unless ${1:${condition}} ${2:${kw}} ${3:${args}}
108+
Run Keyword Unless '\${${1:rc}}' != '${2:abc}' ${3:${kw}} ${4:${args}}
106109
endsnippet
107110

108111
snippet sgv "Set Global Variable"
@@ -130,7 +133,9 @@ snippet sv "Set Variable"
130133
endsnippet
131134

132135
snippet svi "Set Variable If"
133-
\${${1:var}}= Set Variable If ${2:${condition}} ${3:${value true}} ${4:${value false}}
136+
\${${1:var}}= Set Variable If '\${${2:rc}}' != '${3:abc}'
137+
`!p snip.rv = '...' + ' ' * (len(t[1]) + 23)` ${4:${value true}}
138+
`!p snip.rv = '...' + ' ' * (len(t[1]) + 23)` ${5:${value false}}
134139
endsnippet
135140

136141
snippet wuks "Wait Until Keyword Succeeds"

0 commit comments

Comments
 (0)