File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1
1
use v6 ;
2
+ use lib <t/spec/packages/ >;
2
3
use Test ;
4
+ use Test ::Util;
3
5
4
- plan 3 ;
6
+ plan 4 ;
5
7
6
8
# RT #123520
7
9
# This test comes first in the file so it's the first to start any threads;
@@ -23,3 +25,7 @@ plan 3;
23
25
is $ p . result, True , " Promise.at result is True" ;
24
26
ok now - $ start >= 1 , " Promise.at took long enough" ;
25
27
}
28
+
29
+ is_run 「 await Promise.at(now - 1000).then: {print 'pass'}」 ,
30
+ {: out<pass >, : err(' ' ), : 0 status},
31
+ ' .at with negative value works and does not warn' ;
Original file line number Diff line number Diff line change 1
1
use v6 ;
2
2
use Test ;
3
3
4
- plan 3 ;
4
+ plan 4 ;
5
5
6
6
# RT #123520
7
7
# This test comes first in the file so it's the first to start any threads;
@@ -23,3 +23,8 @@ plan 3;
23
23
is $ p . result, True , " Promise.in result is True" ;
24
24
ok now - $ start >= 1 , " Promise.in took long enough" ;
25
25
}
26
+
27
+ subtest ' Promise.in with negative value works' => {
28
+ plan 1 ;
29
+ await Promise . in(-rand). then: { pass " .then'ed code ran" }
30
+ }
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use Test;
5
5
use Test ::Tap;
6
6
use Test ::Util;
7
7
8
- plan 8 ;
8
+ plan 9 ;
9
9
10
10
dies-ok { Supplier. new . Supply . interval(1 ) }, ' can not be called as an instance method' ;
11
11
@@ -48,14 +48,31 @@ is_run(
48
48
49
49
# RT #130168
50
50
{
51
+ # treat too-small values as minimum timer resolution (e.g. 0.001 seconds)
52
+ # emitting optional warning in such cases is allowed
53
+ CONTROL { when CX::Warn { . resume } }
51
54
my @ a ;
52
55
react {
53
56
whenever Supply . interval(.0001 ) {
54
57
push @ a , $ _ ;
55
58
done if $ _ == 5
56
59
}
57
60
}
58
- is @ a , [0 .. 5 ], " Timer with very short interval fires multiple times" ;
61
+ is-deeply @ a , [0 .. 5 ], " Timer with very short interval fires multiple times" ;
62
+ }
63
+
64
+ {
65
+ # treat negatives/zeros as minimum timer resolution (e.g. 0.001 seconds)
66
+ # emitting optional warning in such cases is allowed
67
+ CONTROL { when CX::Warn { . resume } }
68
+ my @ a ;
69
+ react {
70
+ whenever Supply . interval(-100 ) {
71
+ push @ a , $ _ ;
72
+ done if $ _ == 5
73
+ }
74
+ }
75
+ is-deeply @ a , [0 .. 5 ], " Timer with very short interval fires multiple times" ;
59
76
}
60
77
61
78
# vim: ft=perl6 expandtab sw=4
You can’t perform that action at this time.
0 commit comments