Skip to content

Commit

Permalink
Fix all warnings (unused imports)
Browse files Browse the repository at this point in the history
Also, dartfmt.
  • Loading branch information
Brian Slesinsky committed May 2, 2016
1 parent 18627bc commit da26419
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion benchmark/lib/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'generated/benchmark.pb.dart' as pb;
import 'benchmark.dart' show Profiler;
import 'dashboard_model.dart' show DashboardModel, Table, SelectEvent;
import 'dashboard_view.dart' show DashboardView;
import 'report.dart' show createPlatform, createPackages, encodeReport;
import 'report.dart' show createPlatform, createPackages;
import 'suite.dart' show runSuite;

import '../data/index.dart' as data;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/lib/suites/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../benchmarks/int64_json.dart';
import '../benchmarks/repeated_int64_json.dart';
import '../benchmarks/string_json.dart';
import '../benchmarks/repeated_string_json.dart';
import '../generated/benchmark.pb.dart' show Request, Suite;
import '../generated/benchmark.pb.dart' show Suite;

final jsonSuite = () {
var suite = new Suite();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/lib/suites/props.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ library protoc.benchmark.suite.json;
import '../benchmarks/get_strings.dart';
import '../benchmarks/set_strings.dart';
import '../benchmarks/has_strings.dart';
import '../generated/benchmark.pb.dart' show Request, Suite;
import '../generated/benchmark.pb.dart' show Suite;

final propsSuite = () {
var suite = new Suite();
Expand Down
46 changes: 28 additions & 18 deletions test/map_test.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
library map_test;

import 'package:test/test.dart'
show test, expect, predicate, same, throwsA,
throwsArgumentError, throwsUnsupportedError;
show test, expect, predicate, same, throwsA, throwsArgumentError;

import '../out/protos/map_api.pb.dart' as pb;
import '../out/protos/map_api2.pb.dart' as pb2;

throwsError(Type expectedType, String expectedMessage) =>
throwsA(predicate((x) {
expect(x.runtimeType, expectedType);
expect(x.message, expectedMessage);
return true;
}));
throwsA(predicate((x) {
expect(x.runtimeType, expectedType);
expect(x.message, expectedMessage);
return true;
}));

void main() {

test("message doesn't implement Map when turned off", () {
expect(new pb.NonMap(), predicate((x) => x is !Map));
expect(new pb2.NonMap2(), predicate((x) => x is !Map));
expect(new pb.NonMap(), predicate((x) => x is! Map));
expect(new pb2.NonMap2(), predicate((x) => x is! Map));
});

test("message implements Map when turned on", () {
Expand Down Expand Up @@ -56,20 +54,27 @@ void main() {

test('operator []= throws exception for invalid key', () {
var rec = new pb.Rec();
expect(() { rec["unknown"] = 123; },
throwsError(ArgumentError, "field 'unknown' not found in Rec"));
expect(() {
rec["unknown"] = 123;
}, throwsError(ArgumentError, "field 'unknown' not found in Rec"));
});

test('operator []= throws exception for repeated field', () {
// Copying the values would be confusing.
var rec = new pb.Rec();
expect(() { rec["nums"] = [1, 2]; }, throwsArgumentError);
expect(() {
rec["nums"] = [1, 2];
}, throwsArgumentError);
});

test('operator []= throws exception for invalid value type', () {
var rec = new pb.Rec();
expect(() { rec["num"] = "hello"; }, throwsArgumentError);
expect(() { rec["str"] = 123; }, throwsArgumentError);
expect(() {
rec["num"] = "hello";
}, throwsArgumentError);
expect(() {
rec["str"] = 123;
}, throwsArgumentError);
});

test('operator []= sets the field', () {
Expand Down Expand Up @@ -104,8 +109,9 @@ void main() {
test("remove isn't supported", () {
var rec = new pb.Rec();
rec.str = "hello";
expect(() { rec.remove("str"); },
throwsError(UnsupportedError, "remove() not supported by Rec"));
expect(() {
rec.remove("str");
}, throwsError(UnsupportedError, "remove() not supported by Rec"));
expect(rec.str, "hello");
});

Expand All @@ -132,6 +138,10 @@ void main() {
test("addAll doesn't work for repeated fields", () {
// It would be confusing to copy the values.
var rec = new pb.Rec();
expect(() { rec.addAll({"nums": [1,2,3]}); }, throwsArgumentError);
expect(() {
rec.addAll({
"nums": [1, 2, 3]
});
}, throwsArgumentError);
});
}

0 comments on commit da26419

Please sign in to comment.