diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-09 18:29:31 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-11 10:25:02 +0300 |
commit | e1da4d682173d6adbc0e5c99ec1b3c8c9a948957 (patch) | |
tree | 5ca5df253b716d9a9672eee8dc9bdee10cb2d58e /tests | |
parent | 8483129b6a4746247fd7fb3b5554e10181ad937a (diff) |
Add date builtin
Diffstat (limited to 'tests')
-rw-r--r-- | tests/builtin/date.testscript | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/builtin/date.testscript b/tests/builtin/date.testscript new file mode 100644 index 0000000..0b466c3 --- /dev/null +++ b/tests/builtin/date.testscript @@ -0,0 +1,48 @@ +# file : tests/builtin/date.testscript +# license : MIT; see accompanying LICENSE file + +test.arguments = "date" + +: timezone +: +: Here we also make sure that the dates are not only verified but can also be +: seen if running with the verbosity level 2 and up, which helps with +: troubleshooting. +: +{ + $* | set local; + $* --utc | set utc; + + echo "local: $local" >~'%local: \S+ \S+ .+ \d{2}:\d{2}:\d{2} .+ \d+%'; + echo "utc: $utc" >~'%utc: \S+ \S+ .+ \d{2}:\d{2}:\d{2} .+ \d+%' +} + +: format +: +{ + : non-empty + : + $* '+%Y-%m-%d %H:%M:%S%[.N]' >~'%\d+-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{9}%' + + : empty + : + $* '+' >'' + + : no-leading-plus + : + $* '%Y-%m-%d %H:%M:%S' 2>>EOE!= 0 + date: date format argument must start with '+' + EOE +} + +: unknown-option +: +$* -d '+%Y-%m-%d %H:%M:%S' 2>>EOE!= 0 + date: unknown option '-d' + EOE + +: unexpected-arg +: +$* '+%Y-%m-%d %H:%M:%S' '%Y' 2>>EOE!= 0 + date: unexpected argument '%Y' + EOE |