-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test case files were copied from: - https://github.com/magicant/yash-rs/blob/8a58f1fd1f3f3cd5c8c7399b07e91da1c97cf71d/yash-cli/tests/scripted_test/declutil-p.sh - https://github.com/magicant/yash-rs/blob/8a58f1fd1f3f3cd5c8c7399b07e91da1c97cf71d/yash-cli/tests/scripted_test/declutil-y.sh
- Loading branch information
Showing
4 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# declutil-p.tst: test of declaration utilities for any POSIX-compliant shell | ||
|
||
posix="true" | ||
|
||
# Pathname expansion may match this dummy file in incorrect implementations. | ||
>tmpfile | ||
|
||
test_oE 'no pathname expansion or field splitting in export A=$a' | ||
a="1 * 2" | ||
export A=$a | ||
sh -c 'printf "%s\n" "$A"' | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
test_oE 'tilde expansions in export A=~:~' | ||
HOME=/foo | ||
export A=~:~ | ||
sh -c 'printf "%s\n" "$A"' | ||
__IN__ | ||
/foo:/foo | ||
__OUT__ | ||
|
||
test_oE 'pathname expansion and field splitting in export $a' | ||
A=foo B=bar a='A B' | ||
export $a | ||
sh -c 'printf "%s\n" "$A" "$B"' | ||
__IN__ | ||
foo | ||
bar | ||
__OUT__ | ||
|
||
test_oE 'no pathname expansion or field splitting in readonly A=$a' | ||
a="1 * 2" | ||
readonly A=$a | ||
printf "%s\n" "$A" | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
test_oE 'tilde expansions in readonly A=~:~' | ||
HOME=/foo | ||
readonly A=~:~ | ||
printf "%s\n" "$A" | ||
__IN__ | ||
/foo:/foo | ||
__OUT__ | ||
|
||
test_oE 'pathname expansion and field splitting in readonly $a' | ||
A=foo B=bar a='A B' | ||
readonly $a | ||
printf "%s\n" "$A" "$B" | ||
__IN__ | ||
foo | ||
bar | ||
__OUT__ | ||
|
||
test_oE 'command command export' | ||
a="1 * 2" | ||
command command export A=$a | ||
sh -c 'printf "%s\n" "$A"' | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
test_oE 'command command readonly' | ||
a="1 * 2" | ||
command command readonly A=$a | ||
printf "%s\n" "$A" | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
# POSIX allows any utility to be a declaration utility as an extension, | ||
# so there are no tests to check that a utility is not a declaration utility. | ||
|
||
# vim: set ft=sh ts=8 sts=4 sw=4 et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# declutil-y.tst: yash-specific test of declaration utilities | ||
|
||
>tmpfile | ||
|
||
# local is a declaration utility in yash | ||
test_oE 'no pathname expansion or field splitting in local A=$a' | ||
a="1 * 2" | ||
local A=$a | ||
printf "%s\n" "$A" | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
# typeset is a declaration utility in yash | ||
test_oE 'no pathname expansion or field splitting in typeset A=$a' | ||
a="1 * 2" | ||
typeset A=$a | ||
printf "%s\n" "$A" | ||
__IN__ | ||
1 * 2 | ||
__OUT__ | ||
|
||
# printf is not a declaration utility in yash | ||
test_oE 'pathname expansion and field splitting in printf A=$a' | ||
a='1 tmp* 2' | ||
printf "%s\n" A=$a | ||
__IN__ | ||
A=1 | ||
tmpfile | ||
2 | ||
__OUT__ | ||
|
||
# printf is not a declaration utility in yash | ||
test_oE 'tilde expansions in printf A=~:~' | ||
HOME=/foo | ||
printf "%s\n" A=~:~ | ||
__IN__ | ||
A=~:~ | ||
__OUT__ | ||
|
||
# printf is not a declaration utility in yash | ||
test_oE 'command command printf' | ||
a='1 tmp* 2' | ||
command command printf "%s\n" A=$a | ||
__IN__ | ||
A=1 | ||
tmpfile | ||
2 | ||
__OUT__ | ||
|
||
# vim: set ft=sh ts=8 sts=4 sw=4 et: |