@@ -138,5 +138,59 @@ public void SelectionStatements_Switch()
138138 File . Delete ( path ) ;
139139 }
140140 }
141+
142+ [ Fact ]
143+ public void AsyncAwait ( )
144+ {
145+ string path = Path . GetTempFileName ( ) ;
146+ try
147+ {
148+ RemoteExecutor . Invoke ( async pathSerialize =>
149+ {
150+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < AsyncAwait > ( instance =>
151+ {
152+ instance . SyncExecution ( ) ;
153+
154+ int res = ( ( Task < int > ) instance . AsyncExecution ( true ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
155+ res = ( ( Task < int > ) instance . AsyncExecution ( 1 ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
156+ res = ( ( Task < int > ) instance . AsyncExecution ( 2 ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
157+ res = ( ( Task < int > ) instance . AsyncExecution ( 3 ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
158+ res = ( ( Task < int > ) instance . ContinuationCalled ( ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
159+
160+ return Task . CompletedTask ;
161+ } , pathSerialize ) ;
162+ return 0 ;
163+ } , path ) . Dispose ( ) ;
164+
165+ CoverageResult result = TestInstrumentationHelper . GetCoverageResult ( path ) ;
166+ result . Document ( "Instrumentation.AsyncAwait.cs" )
167+ . AssertLinesCovered ( BuildConfiguration . Debug ,
168+ // AsyncExecution(bool)
169+ ( 10 , 1 ) , ( 11 , 1 ) , ( 12 , 1 ) , ( 14 , 1 ) , ( 16 , 1 ) , ( 17 , 0 ) , ( 18 , 0 ) , ( 19 , 0 ) , ( 21 , 1 ) , ( 22 , 1 ) ,
170+ // Async
171+ ( 25 , 9 ) , ( 26 , 9 ) , ( 27 , 9 ) , ( 28 , 9 ) ,
172+ // SyncExecution
173+ ( 31 , 1 ) , ( 32 , 1 ) , ( 33 , 1 ) ,
174+ // Sync
175+ ( 36 , 1 ) , ( 37 , 1 ) , ( 38 , 1 ) ,
176+ // AsyncExecution(int)
177+ ( 41 , 3 ) , ( 42 , 3 ) , ( 43 , 3 ) , ( 46 , 1 ) , ( 47 , 1 ) , ( 48 , 1 ) , ( 51 , 1 ) ,
178+ ( 52 , 1 ) , ( 53 , 1 ) , ( 56 , 1 ) , ( 57 , 1 ) , ( 58 , 1 ) , ( 59 , 1 ) ,
179+ ( 62 , 0 ) , ( 63 , 0 ) , ( 64 , 0 ) , ( 65 , 0 ) , ( 68 , 0 ) , ( 70 , 3 ) , ( 71 , 3 ) ,
180+ // ContinuationNotCalled
181+ ( 74 , 0 ) , ( 75 , 0 ) , ( 76 , 0 ) , ( 77 , 0 ) , ( 78 , 0 ) ,
182+ // ContinuationCalled -> line 83 should be 1 hit some issue with Continuation state machine
183+ ( 81 , 1 ) , ( 82 , 1 ) , ( 83 , 2 ) , ( 84 , 1 ) , ( 85 , 1 )
184+ )
185+ . AssertBranchesCovered ( BuildConfiguration . Debug , ( 16 , 0 , 0 ) , ( 16 , 1 , 1 ) , ( 43 , 0 , 3 ) , ( 43 , 1 , 1 ) , ( 43 , 2 , 1 ) , ( 43 , 3 , 1 ) , ( 43 , 4 , 0 ) )
186+ // Real branch should be 2, we should try to remove compiler generated branch in method ContinuationNotCalled/ContinuationCalled
187+ // for Continuation state machine
188+ . ExpectedTotalNumberOfBranches ( BuildConfiguration . Debug , 4 ) ;
189+ }
190+ finally
191+ {
192+ File . Delete ( path ) ;
193+ }
194+ }
141195 }
142196}
0 commit comments