summaryrefslogtreecommitdiffstats
path: root/tests/casemod.tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:33:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:33:23 +0000
commit1d5cace9db9aef76f26b2d7ba54bbb76443b00b2 (patch)
tree314a15dd1aa103da13bdc83ba1d2105a290bc5ba /tests/casemod.tests
parentInitial commit. (diff)
downloadbash-1d5cace9db9aef76f26b2d7ba54bbb76443b00b2.tar.xz
bash-1d5cace9db9aef76f26b2d7ba54bbb76443b00b2.zip
Adding upstream version 5.0.upstream/5.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/casemod.tests')
-rw-r--r--tests/casemod.tests113
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/casemod.tests b/tests/casemod.tests
new file mode 100644
index 0000000..dacdb0a
--- /dev/null
+++ b/tests/casemod.tests
@@ -0,0 +1,113 @@
+S1=acknowledgement
+S2=oenophile
+
+echo ${S1^}
+echo ${S1^^}
+
+echo ${S2^[aeiou]}
+echo ${S2^^[aeiou]}
+
+U1=${S1^^}
+U2=${S2^^}
+
+echo ${U1,}
+echo ${U1,,}
+
+echo ${U2,}
+echo ${U2,[AEIOU]}
+echo ${U2,,[AEIOU]}
+
+A1=( $S1 $S2 )
+
+echo ${A1[@]^[aeiou]}
+echo ${A1[@]^^[aeiou]}
+
+A2=( $U1 $U2 )
+
+echo ${A2[@],[AEIOU]}
+echo ${A2[@],,[AEIOU]}
+
+echo ${A2[@],?}
+echo ${A2[@],,?}
+
+declare -A AA1 AA2
+
+AA1[ack]=$S1
+AA1[oen]=$S2
+
+echo ${AA1[@]^}
+echo ${AA1[@]^^}
+
+echo ${AA1[@]^[aeiou]}
+echo ${AA1[@]^^[aeiou]}
+
+AA2[ACK]=$U1
+AA2[OEN]=$U2
+
+echo ${AA2[@],}
+echo ${AA2[@],,}
+
+echo ${AA2[@],[AEIOU]}
+echo ${AA2[@],,[AEIOU]}
+
+set -- $S1 $S2
+
+echo ${@^}
+echo ${@^^}
+
+
+echo ${S1^[rstlne]} ${S2^[rstlne]}
+echo ${S1^^[rstlne]} ${S2^^[rstlne]}
+
+echo ${@^[rstlne]}
+echo ${@^^[rstlne]}
+
+echo ${S1,[rstlne]} ${S2,[rstlne]}
+echo ${S1,,[rstlne]} ${S2,,[rstlne]}
+
+echo ${@,[rstlne]}
+echo ${@,,[rstlne]}
+
+echo ${@^?}
+echo ${@^^?}
+
+# make sure that multiple words in the string are handled as other expansions
+TEXT="Be Conservative in what you send and Liberal in what you accept"
+TEXT2="be conservative in what you send and liberal in what you accept"
+
+declare -u foo
+foo=$TEXT
+echo $foo
+
+declare -l bar
+bar=$TEXT
+echo $bar
+
+declare -c qux
+qux=$TEXT
+echo $qux
+qux=$TEXT2
+echo $qux
+
+echo ${TEXT,}
+echo ${TEXT,,}
+
+echo ${TEXT^}
+echo ${TEXT^^}
+
+echo ${TEXT2^}
+echo ${TEXT2^^}
+
+M1=${S1^^[aeiou]}
+M2=${U2,,[AEIOU]}
+
+echo ${M1} ${M1~}
+echo ${M2} ${M2~~}
+
+declare -l lower=aBcDe
+lower+=XyZ
+echo $lower
+
+declare -u upper=aBcDe
+upper+=xYZ
+echo $upper