5
5
/// Unit tests for lib/src/experiment_options.dart.
6
6
library dartdoc.experiment_options_test;
7
7
8
- import 'dart:cli' ;
9
8
import 'dart:io' ;
10
9
11
10
import 'package:analyzer/src/dart/analysis/experiments.dart' ;
@@ -19,9 +18,9 @@ void main() {
19
18
ExperimentalFeature defaultOnNotExpired, defaultOffNotExpired;
20
19
ExperimentalFeature defaultOnExpired, defaultOffExpired;
21
20
22
- void withSyntheticExperimentalFeatures (
23
- void Function () operation,
24
- ) {
21
+ Future < void > withSyntheticExperimentalFeatures (
22
+ Future < void > Function () operation,
23
+ ) async {
25
24
defaultOnNotExpired = ExperimentalFeature (
26
25
index: 0 ,
27
26
enableString: 'a' ,
@@ -55,16 +54,14 @@ void main() {
55
54
firstSupportedVersion: null ,
56
55
);
57
56
58
- overrideKnownFeatures (
57
+ await overrideKnownFeaturesAsync (
59
58
{
60
59
'a' : defaultOnNotExpired,
61
60
'b' : defaultOffNotExpired,
62
61
'c' : defaultOnExpired,
63
62
'd' : defaultOffExpired,
64
63
},
65
- () {
66
- operation ();
67
- },
64
+ operation,
68
65
);
69
66
}
70
67
@@ -78,25 +75,20 @@ void main() {
78
75
});
79
76
80
77
group ('Experimental options test' , () {
81
- void withExperimentOptions (
78
+ Future < void > withExperimentOptions (
82
79
void Function (DartdocOptionSet ) operation,
83
- ) {
84
- withSyntheticExperimentalFeatures (() {
85
- // The enclosing function expects only synchronous function argument.
86
- // But `fromOptionGenerators` is asynchronous.
87
- // So, we have to use `waitFor` to adapt it.
88
- var experimentOptions = waitFor (
89
- DartdocOptionSet .fromOptionGenerators (
90
- 'dartdoc' ,
91
- [createExperimentOptions],
92
- ),
80
+ ) async {
81
+ await withSyntheticExperimentalFeatures (() async {
82
+ var experimentOptions = await DartdocOptionSet .fromOptionGenerators (
83
+ 'dartdoc' ,
84
+ [createExperimentOptions],
93
85
);
94
86
operation (experimentOptions);
95
87
});
96
88
}
97
89
98
- test ('Defaults work for all options' , () {
99
- withExperimentOptions ((experimentOptions) {
90
+ test ('Defaults work for all options' , () async {
91
+ await withExperimentOptions ((experimentOptions) {
100
92
experimentOptions.parseArguments ([]);
101
93
var tester = DartdocOptionContext (experimentOptions, emptyTempDir);
102
94
expect (tester.experimentStatus.isEnabled (defaultOnNotExpired), isTrue);
@@ -107,8 +99,8 @@ void main() {
107
99
});
108
100
});
109
101
110
- test ('Overriding defaults works via args' , () {
111
- withExperimentOptions ((experimentOptions) {
102
+ test ('Overriding defaults works via args' , () async {
103
+ await withExperimentOptions ((experimentOptions) {
112
104
// Set all experiments to non-default values.
113
105
experimentOptions.parseArguments ([
114
106
'--enable-experiment' ,
0 commit comments