Skip to content

Commit

Permalink
Enable Travis-CI (flutter#7)
Browse files Browse the repository at this point in the history
Fixes flutter#6
  • Loading branch information
kevmoo authored and nex3 committed Mar 1, 2018
1 parent 005fab6 commit 7edabc9
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 20 deletions.
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: dart

dart:
- dev
- stable

dart_task:
- test: --platform vm,chrome

matrix:
include:
# Only validate formatting using the dev release
- dart: dev
dart_task: dartfmt
- dart: dev
dart_task: analyzer

# Only building master means that we don't run two builds for each pull request.
branches:
only: [master]

cache:
directories:
- $HOME/.pub-cache
File renamed without changes.
5 changes: 2 additions & 3 deletions lib/src/eager_span_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class EagerSpanScanner extends SpanScanner {
if (newlines.isEmpty) {
_column -= oldPosition - newPosition;
} else {
_column = newPosition -
string.lastIndexOf(_newlineRegExp, newPosition) - 1;
_column =
newPosition - string.lastIndexOf(_newlineRegExp, newPosition) - 1;
}
}
}
Expand Down Expand Up @@ -121,4 +121,3 @@ class _EagerSpanScannerState implements LineScannerState {

_EagerSpanScannerState(this._scanner, this.position, this.line, this.column);
}

4 changes: 2 additions & 2 deletions lib/src/line_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class LineScanner extends StringScanner {
if (newlines.isEmpty) {
_column -= oldPosition - newPosition;
} else {
_column = newPosition -
string.lastIndexOf(_newlineRegExp, newPosition) - 1;
_column =
newPosition - string.lastIndexOf(_newlineRegExp, newPosition) - 1;
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions lib/src/relative_span_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ class RelativeSpanScanner extends StringScanner implements SpanScanner {
/// This is used to convert between span-relative and file-relative fields.
final FileLocation _startLocation;

int get line => _sourceFile.getLine(_startLocation.offset + position) -
int get line =>
_sourceFile.getLine(_startLocation.offset + position) -
_startLocation.line;

int get column {
var line = _sourceFile.getLine(_startLocation.offset + position);
var column = _sourceFile.getColumn(_startLocation.offset + position,
line: line);
var column =
_sourceFile.getColumn(_startLocation.offset + position, line: line);
return line == _startLocation.line
? column - _startLocation.column
: column;
Expand Down Expand Up @@ -66,8 +67,7 @@ class RelativeSpanScanner extends StringScanner implements SpanScanner {

FileSpan spanFrom(LineScannerState startState, [LineScannerState endState]) {
var endPosition = endState == null ? position : endState.position;
return _sourceFile.span(
_startLocation.offset + startState.position,
return _sourceFile.span(_startLocation.offset + startState.position,
_startLocation.offset + endPosition);
}

Expand All @@ -77,8 +77,7 @@ class RelativeSpanScanner extends StringScanner implements SpanScanner {
return false;
}

_lastSpan = _sourceFile.span(
_startLocation.offset + position,
_lastSpan = _sourceFile.span(_startLocation.offset + position,
_startLocation.offset + lastMatch.end);
return true;
}
Expand All @@ -92,8 +91,7 @@ class RelativeSpanScanner extends StringScanner implements SpanScanner {
}
if (length == null) length = match == null ? 1 : match.end - match.start;

var span = _sourceFile.span(
_startLocation.offset + position,
var span = _sourceFile.span(_startLocation.offset + position,
_startLocation.offset + position + length);
throw new StringScannerException(message, span, string);
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/span_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SpanScanner extends StringScanner implements LineScanner {
if (lastMatch == null) _lastSpan = null;
return _lastSpan;
}

FileSpan _lastSpan;

/// The current location of the scanner.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/string_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class StringScanner {
_position = position;
_lastMatch = null;
}

int _position = 0;

/// The data about the previous match made by the scanner.
Expand All @@ -45,6 +46,7 @@ class StringScanner {
if (_position != _lastMatchPosition) _lastMatch = null;
return _lastMatch;
}

Match _lastMatch;
int _lastMatchPosition;

Expand Down
10 changes: 5 additions & 5 deletions test/span_scanner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import 'package:test/test.dart';
import 'utils.dart';

void main() {
testForImplementation("lazy", ([string]) {
testForImplementation("lazy", ([String string]) {
return new SpanScanner(string ?? 'foo\nbar\nbaz', sourceUrl: 'source');
});

testForImplementation("eager", ([string]) {
testForImplementation("eager", ([String string]) {
return new SpanScanner.eager(string ?? 'foo\nbar\nbaz',
sourceUrl: 'source');
});
Expand Down Expand Up @@ -93,8 +93,8 @@ void main() {

test(".error() uses an absolute span", () {
scanner.expect("foo");
expect(() => scanner.error('oh no!'),
throwsStringScannerException("foo"));
expect(
() => scanner.error('oh no!'), throwsStringScannerException("foo"));
});

test(".isDone returns true at the end of the span", () {
Expand All @@ -104,7 +104,7 @@ void main() {
});
}

void testForImplementation(String name, SpanScanner create()) {
void testForImplementation(String name, SpanScanner create([String string])) {
group("for a $name scanner", () {
var scanner;
setUp(() => scanner = create());
Expand Down
3 changes: 2 additions & 1 deletion test/string_scanner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ void main() {
expect(scanner.rest, equals(' bar'));
});

test("a non-matching expect throws a FormatException and sets lastMatch to "
test(
"a non-matching expect throws a FormatException and sets lastMatch to "
"null", () {
expect(scanner.matches(new RegExp('f(..)')), isTrue);
expect(scanner.lastMatch, isNotNull);
Expand Down

0 comments on commit 7edabc9

Please sign in to comment.