From f7dbd14a87bfb17a5f376c571d7de28243fcf54e Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 24 Oct 2020 18:27:54 +0330 Subject: [PATCH] Shell: Add some tests for brace expansions --- Shell/Tests/brace-exp.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Shell/Tests/brace-exp.sh diff --git a/Shell/Tests/brace-exp.sh b/Shell/Tests/brace-exp.sh new file mode 100644 index 0000000000..e960c66d68 --- /dev/null +++ b/Shell/Tests/brace-exp.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +setopt --verbose + +fail() { + echo $* + exit 1 +} + +test "$(echo {a,b,})" = "a b " || fail normal brace expansion with one empty slot +test "$(echo {a,,b})" = "a b" || fail normal brace expansion with one empty slot +test "$(echo {a,,,b})" = "a b" || fail normal brace expansion with two empty slots +test "$(echo {a,b,,})" = "a b " || fail normal brace expansion with two empty slots + +test "$(echo {a..c})" = "a b c" || fail range brace expansion, alpha +test "$(echo {0..3})" = "0 1 2 3" || fail range brace expansion, number +test "$(echo {😂..😄})" = "😂 😃 😄" || fail range brace expansion, unicode codepoint + +# Make sure that didn't mess with dots and commas in normal barewords +test .. = ".." || fail range brace expansion delimiter affects normal barewords +test , = "," || fail normal brace expansion delimiter affects normal barewords