public async Task TestTokenIteration(IList<Token> expectedTokens) { using (var tokenIterator = new AsyncLATokenIterator(expectedTokens.AsAsync())) { for (var i = 0; i < expectedTokens.Count; i++) { Assert.That(await tokenIterator.MoveNextAsync(), Is.True, "Move next i={0}", i); var current = await tokenIterator.CurrentAsync(); Assert.That(current, Is.EqualTo(expectedTokens[i]), "Current i={0} expected={1} is={2}", i, expectedTokens[i], current); var la = await tokenIterator.LookAheadAsync(); var expectedLA = i + 1 < expectedTokens.Count ? expectedTokens[i + 1] : Token.EOF; Assert.That(la, Is.EqualTo(expectedLA), "Lookahead i={0} expected={1} is={2}", i, expectedLA, la); } } }
public async Task TestTokenIteration(IList <Item> expectedTokens) { using (var tokenIterator = new AsyncLATokenIterator(expectedTokens.AsAsync())) { for (var i = 0; i < expectedTokens.Count; i++) { Assert.That(await tokenIterator.MoveNextAsync(), Is.True, "Move next i={0}", i); var current = await tokenIterator.CurrentAsync(); Assert.That(current, Is.EqualTo(expectedTokens[i]), "Current i={0} expected={1} is={2}", i, expectedTokens[i], current); var la = await tokenIterator.LookAheadAsync(); var expectedLA = i + 1 < expectedTokens.Count ? expectedTokens[i + 1] : Item.EOF; Assert.That(la, Is.EqualTo(expectedLA), "Lookahead i={0} expected={1} is={2}", i, expectedLA, la); } } }