| 993 | } |
| 994 | |
| 995 | void TCoroTest::TestOverrideTime() { |
| 996 | class TTime: public NCoro::ITime { |
| 997 | public: |
| 998 | TInstant Now() override { |
| 999 | return Current; |
| 1000 | } |
| 1001 | |
| 1002 | TInstant Current = TInstant::Zero(); |
| 1003 | }; |
| 1004 | |
| 1005 | TTime time; |
| 1006 | TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing(), &time}; |
| 1007 | |
| 1008 | executor.CreateOwned([&](TCont* cont) { |
| 1009 | UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Zero()); |
| 1010 | time.Current = TInstant::Seconds(1); |
| 1011 | cont->SleepD(TInstant::Seconds(1)); |
| 1012 | UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Seconds(1)); |
| 1013 | }, "coro"); |
| 1014 | |
| 1015 | executor.Execute(); |
| 1016 | } |
| 1017 | |
| 1018 | void TCoroTest::TestCancelWithException() { |
| 1019 | TContExecutor exec(32000); |