summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/A08time.ztst39
-rw-r--r--Test/D01prompt.ztst7
-rw-r--r--Test/D04parameter.ztst22
3 files changed, 66 insertions, 2 deletions
diff --git a/Test/A08time.ztst b/Test/A08time.ztst
index 22a460f5e..4a41cc76a 100644
--- a/Test/A08time.ztst
+++ b/Test/A08time.ztst
@@ -11,9 +11,44 @@
(time cat) >&/dev/null
0:`time' keyword (status only)
- ( TIMEFMT='%E %mE %uE %* %m%mm %u%uu'; time (:) )
+ ( TIMEFMT='%E %mE %uE %nE %* %m%mm %u%uu %n%nn'; time (:) )
0:`time' keyword with custom TIMEFMT
-*?[0-9]##.[0-9](#c2)s [0-9]##ms [0-9]##us %\* %m%mm %u%uu
+*?[0-9]##.[0-9](#c2)s [0-9]##ms [0-9]##us [0-9]##ns %\* %m%mm %u%uu %n%nn
+
+ ( TIMEFMT='x %U %S %E'; time (:) )
+0:TIMEFMT %[USE] use centisecond precision
+*?x( <0-9>.<00-99>s)(#c3)
+
+ ( TIMEFMT='x %*U %*S %*E'; time (:) )
+0:TIMEFMT %*[USE] use millisecond precision
+*?x( <0-9>.<000-999>)(#c3)
+
+ ( TIMEFMT='%nU %nS'; time (read -k3 -t0.1) )
+1:TIMEFMT %nU and %nS are limited to microsecond precision
+*?[1-9][0-9]#000ns [1-9][0-9]#000ns
+
+# SECONDS (after - before) must be greater than the elapsed time, but not much
+# greater. 25% was picked arbitrarily as something that hopefully will prevent
+# the test from failing on slow machines
+ (
+ typeset -F SECONDS
+ TIMEFMT=%nE
+ a=$SECONDS
+ t=$( (time (read -k3 -t0.1)) 2>&1 )
+ b=$SECONDS
+ s=$(( b - a ))
+ t=$(( ${t%ns}.0 / 10**9 ))
+ echo $s $t $(( s > t )) $(( t > s - (s * 0.25) ))
+ )
+0:`time' elapsed time matches SECONDS
+*>[0-9.]## [0-9.]## 1 1
+
+# Again, the wide range here is an attempt to prevent this test from failing on
+# slow machines. We don't care about the exact time, just that it's vaguely sane
+# and that each representation has the same basis
+ ( TIMEFMT='%E %mE %uE %nE %*E'; time (read -k3 -t0.1) )
+1:TIMEFMT elapsed time values
+*?0.<10-50>s <10-500>ms <100000-500000>us <100000000-500000000>ns 0.<100-500>
time x=1
0:`time' simple assignment
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 55861cca1..f42e19714 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -70,6 +70,13 @@
>true
>false
+ sec=$SECONDS
+ eval "print -P '%(${sec}S.true.false)'"
+ eval "print -P '%($((sec+30))S.true.false)'"
+0:ternary prompt escape with test character S
+>true
+>false
+
print -P 'start %10<...<truncated at 10%<< Not truncated%3< ...<Not shown'
print -P 'start %10>...>truncated at 10%>> Not truncated%3> ...>Not shown'
0:prompt truncation
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 7953827d6..ed25fd7a9 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1550,6 +1550,28 @@
>1
>1
+ # Integer
+ a=$SECONDS
+ sleep 1
+ b=$SECONDS
+ print -r - $a $b $(( b > a ))
+ # Float
+ typeset -F SECONDS
+ a=$SECONDS
+ repeat 10 :
+ b=$SECONDS
+ print -r - $a $b $(( b > a ))
+ # Assignment
+ a=$SECONDS
+ SECONDS=8888
+ repeat 10 :
+ b=$SECONDS
+ print -r - $(( a < 8888 )) $(( b > 8888 ))
+0:SECONDS
+*>[0-9]## [0-9]## 1
+*>[0-9]##.[0-9]## [0-9]##.[0-9]## 1
+*>1 1
+
foo=("|" "?")
[[ "|" = ${(j.|.)foo} ]] && print yes || print no
[[ "|" = ${(j.|.)~foo} ]] && print yes || print no