Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis CI integration #2

Merged
merged 10 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ script:
- pub global activate coverage
- pub global run coverage:collect_coverage --port=8111 -o coverage.json --resume-isolates --wait-paused &
- dart --observe=8111 test/dart_kollection_test.dart
- pub global run coverage:format_coverage --package-root=packages --report-on lib --in coverage.json --out lcov.info --lcov
- pub global run coverage:format_coverage --packages=.packages --report-on lib --in coverage.json --out lcov.info --lcov
after_success:
- bash <(curl -s https://codecov.io/bash)
6 changes: 3 additions & 3 deletions lib/src/collection/list_empty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'package:dart_kollection/src/extension/list_extension_mixin.dart';
class EmptyList<T>
with KIterableExtensionsMixin<T>, KCollectionExtensionMixin<T>, KListExtensionsMixin<T>
implements KList<T> {
@override
List<T> get list => <T>[];

@override
bool contains(T element) => false;

Expand Down Expand Up @@ -65,9 +68,6 @@ class EmptyList<T>

@override
Iterable<T> get iter => DartEmptyIterable();

@override
List<T> get list => <T>[];
}

class _EmptyIterator<T> extends KListIterator<T> {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class DartMap<K, V> with KMapExtensionsMixin<K, V> implements KMap<K, V> {
_map = Map.unmodifiable(map),
super();

@override
Map<K, V> get map => _map;

@override
bool containsKey(K key) => _map.containsKey(key);

Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/map_empty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import 'package:dart_kollection/dart_kollection.dart';
import 'package:dart_kollection/src/extension/map_extensions_mixin.dart';

class EmptyMap<K, V> with KMapExtensionsMixin<K, V> implements KMap<K, V> {
@override
Map<K, V> get map => {};

@override
operator [](K key) => null;

Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/map_mutable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class DartMutableMap<K, V>
_map = map,
super();

@override
Map<K, V> get map => _map;

@override
bool containsKey(K key) => _map.containsKey(key);

Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class DartSet<T> with KIterableExtensionsMixin<T>, KCollectionExtensionMixin<T>
@override
Iterable<T> get iter => _set;

@override
Set<T> get set => _set;

@override
bool contains(T element) => _set.contains(element);

Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/set_empty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import 'package:dart_kollection/src/extension/collection_extension_mixin.dart';
import 'package:dart_kollection/src/extension/iterable_extension_mixin.dart';

class EmptySet<T> with KIterableExtensionsMixin<T>, KCollectionExtensionMixin<T> implements KSet<T> {
@override
Set<T> get set => Set();

@override
bool contains(T element) => false;

Expand Down
3 changes: 3 additions & 0 deletions lib/src/collection/set_mutable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DartMutableSet<T>
@override
Iterable<T> get iter => _set;

@override
Set<T> get set => _set;

@override
bool contains(T element) => _set.contains(element);

Expand Down
5 changes: 5 additions & 0 deletions lib/src/k_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import 'package:dart_kollection/dart_kollection.dart';
* @param V the type of map values. The map is covariant on its value type.
*/
abstract class KMap<K, V> implements KMapExtension<K, V> {
/**
* dart interop map for time critical operations such as sorting
*/
Map<K, V> get map;

// Query Operations
/**
* Returns the number of key/value pairs in the map.
Expand Down
5 changes: 5 additions & 0 deletions lib/src/k_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import 'package:dart_kollection/dart_kollection.dart';
* @param E the type of elements contained in the set. The set is covariant on its element type.
*/
abstract class KSet<T> implements KCollection<T> {
/**
* dart interop set for time critical operations such as sorting
*/
Set<T> get set;

// Query Operations
@override
int get size;
Expand Down
5 changes: 5 additions & 0 deletions test/collection/list_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,10 @@ void main() {
expect(() => empty.subList(-1, -1), throwsA(TypeMatcher<IndexOutOfBoundsException>()));
expect(() => empty.subList(2, 10), throwsA(TypeMatcher<IndexOutOfBoundsException>()));
});

test("access dart list", () {
List<String> list = emptyList<String>().list;
expect(list.length, 0);
});
});
}
6 changes: 6 additions & 0 deletions test/collection/list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,11 @@ void main() {
expect(() => list.subList(3, 1), throwsA(TypeMatcher<ArgumentError>()));
expect(() => list.subList(2, 10), throwsA(TypeMatcher<IndexOutOfBoundsException>()));
});

test("access dart list", () {
List<String> list = listOf<String>(["a", "b", "c"]).list;
expect(list.length, 3);
expect(list, equals(["a", "b", "c"]));
});
});
}
9 changes: 7 additions & 2 deletions test/collection/map_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dart_kollection/dart_kollection.dart';
import 'package:test/test.dart';

void main() {
group('empty list', () {
group('empty map', () {
test("has no elements", () {
final empty = emptyMap<String, Object>();
expect(empty.size, equals(0));
Expand Down Expand Up @@ -46,7 +46,7 @@ void main() {
expect(empty.get(null), isNull);
});

test("is equals to another empty list", () {
test("is equals to another empty map", () {
final empty0 = emptyMap();
final empty1 = emptyMap();

Expand All @@ -69,5 +69,10 @@ void main() {
expect(empty0, equals(empty1));
expect(empty0.hashCode, equals(empty1.hashCode));
});

test("access dart map", () {
final Map<String, int> map = emptyMap<String, int>().map;
expect(map.length, 0);
});
});
}
12 changes: 12 additions & 0 deletions test/collection/map_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:dart_kollection/dart_kollection.dart';
import 'package:test/test.dart';

void main() {
group('basic methods', () {
test("access dart map", () {
Map<String, int> map = mapOf<String, int>({"a": 1, "b": 2}).map;
expect(map.length, 2);
expect(map, equals({"a": 1, "b": 2}));
});
});
}
6 changes: 6 additions & 0 deletions test/collection/set_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,11 @@ void main() {

expect(set0, isNot(equals(set3)));
});

test("access dart set", () {
Set<String> set = setOf<String>(["a", "b", "c"]).set;
expect(set.length, 3);
expect(set, equals(Set.from(["a", "b", "c"])));
});
});
}
20 changes: 20 additions & 0 deletions test/dart_kollection_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'collection/iterable_extensions_test.dart' as iterable_extensions_test;
import 'collection/list_mutable_test.dart' as list_mutable_test;
import 'collection/list_test.dart' as list_test;
import 'collection/map_empty_test.dart' as map_empty_test;
import 'collection/map_extensions_test.dart' as map_extensions_test;
import 'collection/map_test.dart' as map_test;
import 'collection/set_test.dart' as set_test;
import 'collections_test.dart' as collections_test;

main() {
collections_test.main();
iterable_extensions_test.main();
list_test.main();
list_mutable_test.main();
list_test.main();
map_empty_test.main();
map_extensions_test.main();
map_test.main();
set_test.main();
}
17 changes: 17 additions & 0 deletions tool/check_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Determine which files have been modified and should be run through the formatter
dart_files=$(git diff --cached --name-only --diff-filter=ACM | grep '.dart$')
[ -z "$dart_files" ] && exit 0

# Run dartfmt to check if the modified files are properly formatted.
unformatted=$(dartfmt -n ${dart_files})
[ -z "$unformatted" ] && exit 0

# If the files are not properly formatted. Print message and fail.
echo >&2 "The following dart files must be formatted with dartfmt. Please run: dartfmt -w ./**/*.dart from the root of the git repository."
for fn in ${unformatted}; do
echo >&2 "./$fn"
done

exit 1