Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Enable Travis-CI #19

Merged
merged 3 commits into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: dart

dart:
- dev
- stable

dart_task:
- test: --platform vm
# No parallelism on Firefox (-j 1)
# Causes flakiness – need to investigate
- test: --platform firefox -j 1
- dartanalyzer

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

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

cache:
directories:
- $HOME/.pub-cache
1 change: 0 additions & 1 deletion lib/src/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ const String RED = '\u001b[31m';
const String YELLOW = '\u001b[33m';

const String NONE = '\u001b[0m';

7 changes: 3 additions & 4 deletions lib/src/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class SourceFile {
///
/// Use [new SourceFile.fromString] instead.
@Deprecated("Will be removed in 2.0.0")
SourceFile(String text, {url})
: this.decoded(text.runes, url: url);
SourceFile(String text, {url}) : this.decoded(text.runes, url: url);

/// Creates a new source file from [text].
///
Expand Down Expand Up @@ -317,7 +316,6 @@ class _FileSpan extends SourceSpanMixin implements FileSpan {
SourceSpan union(SourceSpan other) {
if (other is! FileSpan) return super.union(other);


_FileSpan span = expand(other);

if (other is _FileSpan) {
Expand All @@ -339,7 +337,8 @@ class _FileSpan extends SourceSpanMixin implements FileSpan {
return super == other && sourceUrl == other.sourceUrl;
}

return _start == other._start && _end == other._end &&
return _start == other._start &&
_end == other._end &&
sourceUrl == other.sourceUrl;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class SourceLocation implements Comparable<SourceLocation> {
}

bool operator ==(other) =>
other is SourceLocation && sourceUrl == other.sourceUrl &&
other is SourceLocation &&
sourceUrl == other.sourceUrl &&
offset == other.offset;

int get hashCode => sourceUrl.hashCode + offset;
Expand Down
1 change: 0 additions & 1 deletion lib/src/location_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ abstract class SourceLocationMixin implements SourceLocation {

String toString() => '<$runtimeType: $offset $toolString>';
}

4 changes: 2 additions & 2 deletions lib/src/span_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ abstract class SourceSpanMixin implements SourceSpan {
return buffer.toString();
}

bool operator ==(other) => other is SourceSpan &&
start == other.start && end == other.end;
bool operator ==(other) =>
other is SourceSpan && start == other.start && end == other.end;

int get hashCode => start.hashCode + (31 * end.hashCode);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/span_with_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SourceSpanWithContext extends SourceSpanBase {
/// [text] should start at `start.column` from the beginning of a line in
/// [context].
SourceSpanWithContext(
SourceLocation start, SourceLocation end, String text, this._context)
SourceLocation start, SourceLocation end, String text, this._context)
: super(start, end, text) {
if (!context.contains(text)) {
throw new ArgumentError(
Expand Down
12 changes: 5 additions & 7 deletions test/file_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ zip zap zop""", url: "foo.dart");
test("column may not be outside the file", () {
expect(() => file.getOffset(2, 100), throwsRangeError);
});

test("column may not be outside the line", () {
expect(() => file.getOffset(1, 20), throwsRangeError);
});
Expand All @@ -109,8 +109,8 @@ zip zap zop""", url: "foo.dart");

group("for span().union()", () {
test("source URLs must match", () {
var other = new SourceSpan(
new SourceLocation(10), new SourceLocation(11), "_");
var other =
new SourceSpan(new SourceLocation(10), new SourceLocation(11), "_");

expect(() => file.span(9, 10).union(other), throwsArgumentError);
});
Expand Down Expand Up @@ -312,10 +312,8 @@ zip zap zop""", url: "bar.dart").span(10, 11);
});

test("returns a base SourceSpan for a SourceSpan input", () {
var other = new SourceSpan(
new SourceLocation(0, sourceUrl: "foo.dart"),
new SourceLocation(5, sourceUrl: "foo.dart"),
"hey, ");
var other = new SourceSpan(new SourceLocation(0, sourceUrl: "foo.dart"),
new SourceLocation(5, sourceUrl: "foo.dart"), "hey, ");
var result = span.union(other);
expect(result, isNot(new isInstanceOf<FileSpan>()));
expect(result.start, equals(other.start));
Expand Down
9 changes: 3 additions & 6 deletions test/highlight_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,19 @@ zip zap zop
});

test("works for a point span in an empty file", () {
expect(new SourceFile("").location(0).pointSpan().highlight(),
equals("""
expect(new SourceFile("").location(0).pointSpan().highlight(), equals("""

^"""));
});

test("works for a single-line file without a newline", () {
expect(new SourceFile("foo bar").span(0, 7).highlight(),
equals("""
expect(new SourceFile("foo bar").span(0, 7).highlight(), equals("""
foo bar
^^^^^^^"""));
});

test("emits tabs for tabs", () {
expect(new SourceFile(" \t \t\tfoo bar").span(5, 8).highlight(),
equals("""
expect(new SourceFile(" \t \t\tfoo bar").span(5, 8).highlight(), equals("""
\t \t\tfoo bar
\t \t\t^^^"""));
});
Expand Down
13 changes: 6 additions & 7 deletions test/location_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:source_span/source_span.dart';
main() {
var location;
setUp(() {
location = new SourceLocation(15,
line: 2, column: 6, sourceUrl: "foo.dart");
location =
new SourceLocation(15, line: 2, column: 6, sourceUrl: "foo.dart");
});

group('errors', () {
Expand All @@ -28,13 +28,13 @@ main() {
});

test('for distance() source URLs must match', () {
expect(() => location.distance(new SourceLocation(0)),
throwsArgumentError);
expect(
() => location.distance(new SourceLocation(0)), throwsArgumentError);
});

test('for compareTo() source URLs must match', () {
expect(() => location.compareTo(new SourceLocation(0)),
throwsArgumentError);
expect(
() => location.compareTo(new SourceLocation(0)), throwsArgumentError);
});
});

Expand Down Expand Up @@ -81,7 +81,6 @@ main() {
});
});


group("equality", () {
test("two locations with the same offset and source are equal", () {
var other = new SourceLocation(15, sourceUrl: "foo.dart");
Expand Down
Loading