fish-shell/tests/checks/count.fish

51 lines
724 B
Fish
Raw Normal View History

2019-06-27 00:57:10 +08:00
#RUN: %fish %s
# Validate the behavior of the `count` command.
2019-06-27 00:57:10 +08:00
# no args
count
2019-06-27 00:57:10 +08:00
# CHECK: 0
2019-06-27 00:57:10 +08:00
# one args
count x
2019-06-27 00:57:10 +08:00
# CHECK: 1
2019-06-27 00:57:10 +08:00
# two args
count x y
2019-06-27 00:57:10 +08:00
# CHECK: 2
2019-06-27 00:57:10 +08:00
# args that look like flags or are otherwise special
count -h
2019-06-27 00:57:10 +08:00
# CHECK: 1
count --help
2019-06-27 00:57:10 +08:00
# CHECK: 1
count --
2019-06-27 00:57:10 +08:00
# CHECK: 1
count -- abc
2019-06-27 00:57:10 +08:00
# CHECK: 2
count def -- abc
2019-06-27 00:57:10 +08:00
# CHECK: 3
2019-02-01 17:58:06 +08:00
2019-06-27 00:57:10 +08:00
# big counts
2019-02-01 17:58:06 +08:00
# See #5611
for i in seq 500
set c1 (count (seq 1 10000))
test $c1 -eq 10000
or begin
echo "Count $c1 is not 10000"
break
end
end
2019-06-27 00:57:10 +08:00
# stdin
# Reading from stdin still counts the arguments
printf '%s\n' 1 2 3 4 5 | count 6 7 8 9 10
2019-06-27 00:57:10 +08:00
# CHECK: 10
# Reading from stdin counts newlines - like `wc -l`.
echo -n 0 | count
2019-06-27 00:57:10 +08:00
# CHECK: 0
echo 1 | count
2019-06-27 00:57:10 +08:00
# CHECK: 1