Skip to content

Commit 87d621b

Browse files
committed
chore(tests): add type-info and array-passing tests
1 parent 3e1203a commit 87d621b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/by-util/test_awk.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,29 @@ fn builtin_isarray_with_array_variable() {
428428
.succeeds()
429429
.stdout_only("1\n1\n");
430430
}
431+
432+
#[test]
433+
fn typeof_basic_usage() {
434+
let tests = [
435+
("BEGIN { print typeof(a) }", "untyped\n"),
436+
(
437+
"BEGIN { print typeof(a+1); print typeof(a) }",
438+
"number\nunassigned\n",
439+
),
440+
("BEGIN { print typeof(\"foo\") }", "string\n"),
441+
(
442+
"BEGIN { print typeof(a[1]); print typeof(a) }",
443+
"untyped\narray\n",
444+
),
445+
];
446+
for (test, expected) in tests {
447+
ucmd().arg(test).succeeds().stdout_only(expected);
448+
}
449+
}
450+
451+
#[test]
452+
fn array_fn_passing() {
453+
ucmd().arg(
454+
"function f(x, y) { print isarray(x); x[2]++ } BEGIN { a[2] = 1; f(a); f(a); print a[2]; }",
455+
).succeeds().stdout_only("1\n1\n3\n");
456+
}

0 commit comments

Comments
 (0)