Skip to content

Commit

Permalink
[v1.1] add regression test (re: 23a6ba0)
Browse files Browse the repository at this point in the history
src/cmd/ksh93/tests/variables.sh:
- Since nrand48(3) uses a POSIX-specified pseudorandom generator on
  all systems, check that a known seed value (123) produces the
  expected reproducable pseudorandom sequence.

Other files:
- Related housekeeping.
  • Loading branch information
McDutchie committed Jan 15, 2025
1 parent 4936d62 commit b508727
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ ksh 93u+m general copyright notice
# Phi <[email protected]> #
# atheik <[email protected]> #
# Vincent Mihalkovic <[email protected]> #
# dnewhall <[email protected]> #
# Ryan Schmidt <[email protected]> #
# Harald van Dijk <[email protected]> #
# Chase <[email protected]> #
# rymrg <[email protected]> #
# hyousatsu <[email protected]> #
# dnewhall <[email protected]> #
# Trey Valenta <[email protected]> #
# Sterling Jensen <[email protected]> #
# Marc Wilson <[email protected]> #
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/ksh93/include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 2.0 *
* *
Expand All @@ -13,6 +13,7 @@
* David Korn <[email protected]> *
* Martijn Dekker <[email protected]> *
* Johnothan King <[email protected]> *
* dnewhall <[email protected]> *
* *
***********************************************************************/

Expand Down
1 change: 1 addition & 0 deletions src/cmd/ksh93/sh/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* hyenias <[email protected]> *
* Harald van Dijk <[email protected]> *
* K. Eugene Carlson <[email protected]> *
* dnewhall <[email protected]> *
* *
***********************************************************************/
/*
Expand Down
1 change: 1 addition & 0 deletions src/cmd/ksh93/sh/subshell.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Martijn Dekker <[email protected]> *
* Johnothan King <[email protected]> *
* hyenias <[email protected]> *
* dnewhall <[email protected]> *
* *
***********************************************************************/
/*
Expand Down
15 changes: 15 additions & 0 deletions src/cmd/ksh93/tests/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1741,5 +1741,20 @@ exp='^[[:digit:]]{8}$'
[[ $got =~ $exp ]] || err_exit '$((.sh.version)) does not yield YYYYMMDD digits' \
"(expected match of ERE $exp, got '$got')"
# ======
# As of 93u+m/1.1, $RANDOM uses nrand48(3) which should use the same pseudorandom
# generator on all systems, producing a known sequence for a given seed value.
case ${.sh.version} in
*93u+m/1.0.*)
;;
*93u+m/*)
RANDOM=123
exp='24979 26943 1328 1988 6255 23944 24547 11971 6923 8339'
got="$RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM"
[[ $got == "$exp" ]] || err_exit "RANDOM does not seem to use the expected pseudorandom generator" \
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
;;
esac
# ======
exit $((Errors<125?Errors:125))

0 comments on commit b508727

Please sign in to comment.