mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[await sync-async flag] Add test of sync async execution (#16795)
This commit is contained in:
parent
3ced55a7dc
commit
00970710e0
26
packages/flutter/test/engine/dart_test.dart
Normal file
26
packages/flutter/test/engine/dart_test.dart
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
/// Verifies Dart semantics governed by flags set by Flutter tooling.
|
||||
void main() {
|
||||
group('Async', () {
|
||||
String greeting = 'hello';
|
||||
Future<void> changeGreeting() async {
|
||||
greeting += ' 1';
|
||||
await new Future<void>.value(null);
|
||||
greeting += ' 2';
|
||||
}
|
||||
test('execution of async method starts synchronously', () async {
|
||||
expect(greeting, 'hello');
|
||||
final Future<void> future = changeGreeting();
|
||||
expect(greeting, 'hello 1');
|
||||
await future;
|
||||
expect(greeting, 'hello 1 2');
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user