mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:10:22 +00:00
6357371c0a
Change-Id: Icf7135ae46159ca834a54849c72405eec83f9b4f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364384 Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Mark Zhou <markzipan@google.com>
51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:reload_test/reload_test_utils.dart';
|
|
import 'dart:async';
|
|
|
|
var counter = 0;
|
|
|
|
Future<void> main() async {
|
|
final periodicTimerDone = Completer();
|
|
|
|
Expect.equals(0, hotReloadGeneration);
|
|
Expect.equals(0, counter++);
|
|
Timer.periodic(Duration(milliseconds: 400), (timer) {
|
|
// Runs in the final generation.
|
|
Expect.equals(2, hotReloadGeneration);
|
|
periodicTimerDone.complete();
|
|
timer.cancel();
|
|
});
|
|
|
|
await Future.delayed(Duration(milliseconds: 20), () {
|
|
Expect.equals(1, counter++);
|
|
});
|
|
|
|
Expect.equals(0, hotReloadGeneration);
|
|
Expect.isFalse(periodicTimerDone.isCompleted);
|
|
|
|
await hotReload();
|
|
|
|
Expect.equals(1, hotReloadGeneration);
|
|
Expect.equals(2, counter++);
|
|
await Future.delayed(Duration(milliseconds: 20), () {
|
|
Expect.equals(3, counter++);
|
|
});
|
|
Expect.equals(1, hotReloadGeneration);
|
|
Expect.isFalse(periodicTimerDone.isCompleted);
|
|
|
|
await hotReload();
|
|
|
|
Expect.isFalse(periodicTimerDone.isCompleted);
|
|
Expect.equals(2, hotReloadGeneration);
|
|
Expect.equals(4, counter++);
|
|
|
|
await periodicTimerDone.future;
|
|
}
|
|
/** DIFF **/
|
|
/*
|
|
*/
|