Ignore comments
This commit is contained in:
parent
659a124478
commit
2691ecf6ee
8 changed files with 29 additions and 37 deletions
|
@ -1,6 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="All Tests" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
||||
<option name="filePath" value="$PROJECT_DIR$/graphql_parser/test/all.dart" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
6
.idea/runConfigurations/tests_in_comment_test_dart.xml
Normal file
6
.idea/runConfigurations/tests_in_comment_test_dart.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="tests in comment_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true" nameIsGenerated="true">
|
||||
<option name="filePath" value="$PROJECT_DIR$/graphql_parser/test/comment_test.dart" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -1,6 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="tests in graphql_parser" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true" nameIsGenerated="true">
|
||||
<option name="filePath" value="$PROJECT_DIR$" />
|
||||
<option name="filePath" value="$PROJECT_DIR$/graphql_parser" />
|
||||
<option name="scope" value="FOLDER" />
|
||||
<option name="testRunnerOptions" value="-j 4" />
|
||||
<method />
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
language: dart
|
||||
dart:
|
||||
- dev
|
||||
- stable
|
||||
script:
|
||||
- travis.sh
|
||||
- bash -ex travis.sh
|
|
@ -3,6 +3,7 @@ import 'syntax_error.dart';
|
|||
import 'token.dart';
|
||||
import 'token_type.dart';
|
||||
|
||||
final RegExp _comment = RegExp(r'#[^\n]*');
|
||||
final RegExp _whitespace = new RegExp('[ \t\n\r]+');
|
||||
final RegExp _boolean = new RegExp(r'true|false');
|
||||
final RegExp _number = new RegExp(r'-?[0-9]+(\.[0-9]+)?(E|e(\+|-)?[0-9]+)?');
|
||||
|
@ -41,7 +42,7 @@ List<Token> scan(String text) {
|
|||
while (!scanner.isDone) {
|
||||
List<Token> potential = [];
|
||||
|
||||
if (scanner.scan(_whitespace)) continue;
|
||||
if (scanner.scan(_comment) || scanner.scan(_whitespace)) continue;
|
||||
|
||||
for (var pattern in _patterns.keys) {
|
||||
if (scanner.matches(pattern)) {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
import 'package:test/test.dart';
|
||||
import 'argument_test.dart' as argument;
|
||||
import 'directive_test.dart' as directive;
|
||||
import 'document_test.dart' as document;
|
||||
import 'field_test.dart' as field;
|
||||
import 'fragment_spread_test.dart' as fragment_spread;
|
||||
import 'inline_fragment_test.dart' as inline_fragment;
|
||||
import 'selection_set_test.dart' as selection_set;
|
||||
import 'type_test.dart' as type;
|
||||
import 'value_test.dart' as value;
|
||||
import 'variable_definition_test.dart' as variable_definition;
|
||||
import 'variable_test.dart' as variable;
|
||||
|
||||
main() {
|
||||
group('argument', argument.main);
|
||||
group('directive', directive.main);
|
||||
group('document', document.main);
|
||||
group('field', field.main);
|
||||
group('fragment spread', fragment_spread.main);
|
||||
group('inline fragment', inline_fragment.main);
|
||||
group('selection set', selection_set.main);
|
||||
group('type', type.main);
|
||||
group('value', value.main);
|
||||
group('variable', variable.main);
|
||||
group('variable definition', variable_definition.main);
|
||||
}
|
16
graphql_parser/test/comment_test.dart
Normal file
16
graphql_parser/test/comment_test.dart
Normal file
|
@ -0,0 +1,16 @@
|
|||
import 'package:graphql_parser/graphql_parser.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('heeds comments', () {
|
||||
var tokens = scan('''
|
||||
# Hello
|
||||
{
|
||||
# Goodbye
|
||||
}
|
||||
# Bonjour
|
||||
''');
|
||||
|
||||
expect(tokens, hasLength(2));
|
||||
});
|
||||
}
|
|
@ -1,4 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -x
|
||||
cd graphql_parser && pub get && pub run test -j2 && cd..
|
Loading…
Reference in a new issue