Skip to content

Commit 4470294

Browse files
committed
tests/expr: check prefix operation
1 parent 17d21d2 commit 4470294

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/by-util/test_expr.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ fn test_parenthesis() {
100100
.args(&["(", "1", "+", "1", ")", "*", "2"])
101101
.succeeds()
102102
.stdout_only("4\n");
103+
104+
new_ucmd!()
105+
.args(&["1", "(", ")"])
106+
.fails()
107+
.stderr_only("expr: syntax error (operation should be prefix)\n");
103108
}
104109

105110
#[test]
@@ -221,6 +226,11 @@ fn test_index() {
221226
.args(&["index", "αbcdef_f", "f"])
222227
.succeeds()
223228
.stdout_only("6\n");
229+
230+
new_ucmd!()
231+
.args(&["αbcdef", "index", "α"])
232+
.fails()
233+
.stderr_only("expr: syntax error (operation should be prefix)\n");
224234
}
225235

226236
#[test]
@@ -234,6 +244,11 @@ fn test_length() {
234244
.args(&["length", "abcdef"])
235245
.succeeds()
236246
.stdout_only("6\n");
247+
248+
new_ucmd!()
249+
.args(&["abcdef", "length"])
250+
.fails()
251+
.stderr_only("expr: syntax error (operation should be prefix)\n");
237252
}
238253

239254
#[test]
@@ -271,6 +286,11 @@ fn test_substr() {
271286
.args(&["substr", "abc", "1", "1"])
272287
.succeeds()
273288
.stdout_only("a\n");
289+
290+
new_ucmd!()
291+
.args(&["abc", "substr", "1", "1"])
292+
.fails()
293+
.stderr_only("expr: syntax error (operation should be prefix)\n");
274294
}
275295

276296
#[test]

0 commit comments

Comments
 (0)