Add next_name_test

This commit is contained in:
Tobe O 2019-03-31 16:21:11 -04:00
parent 915ac255af
commit de6c9f5bef
3 changed files with 24 additions and 0 deletions

View file

@ -27,6 +27,7 @@ class Parser {
bool nextName(String name) {
var tok = peek();
if (tok?.type == TokenType.NAME && tok.span.text == name) {
return next(TokenType.NAME);
}

View file

@ -0,0 +1,18 @@
import 'package:test/test.dart';
import 'common.dart';
var githubSrc = r'''
query searchRepos($queryString: String!, $repositoryOrder: RepositoryOrder, $first: Int!) {
search(type: REPOSITORY, query: $queryString, first: $first) {
...SearchResultItemConnection
}
}
''';
void main() {
test('can parse formerly-reserved words', () {
var def = parse(githubSrc).parseOperationDefinition();
expect(def.isQuery, isTrue);
print(def.variableDefinitions);
});
}

View file

@ -73,6 +73,11 @@ class _IsSelectionSet extends Matcher {
bool matches(item, Map matchState) {
var set =
item is SelectionSetContext ? item : parseSelectionSet(item.toString());
print('Item: $set has ${set.selections.length} selection(s):');
for (var s in set.selections) {
print(' * $s (${s.span.text})');
}
if (set == null) return false;
if (set.selections.length != selections.length) return false;