Add next_name_test
This commit is contained in:
parent
915ac255af
commit
de6c9f5bef
3 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
18
graphql_parser/test/next_name_test.dart
Normal file
18
graphql_parser/test/next_name_test.dart
Normal 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);
|
||||
});
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue