Skip to content

Commit

Permalink
Drop optional new from code in strings (#1134)
Browse files Browse the repository at this point in the history
Remove the `new` from Dart code in strings, docs, comments, and the
README. Leave the keyword if it's used in a doc comment references to
link specifically to the unnamed constructor instead of a class.

Simplify some implementation comments to avoid repeating information.

In some user facing Dart code, switch to single quotes for consistency.
  • Loading branch information
natebosch authored Jan 10, 2020
1 parent d29c10e commit dcd9b51
Show file tree
Hide file tree
Showing 39 changed files with 331 additions and 336 deletions.
209 changes: 104 additions & 105 deletions pkgs/test/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkgs/test/test/runner/browser/chrome_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''').create();

Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/test/runner/browser/firefox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''').create();

Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/test/runner/browser/internet_explorer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''').create();

Expand Down
10 changes: 5 additions & 5 deletions pkgs/test/test/runner/browser/loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main() {
void main() {
test("success", () {});
test("failure", () => throw new TestFailure('oh no'));
test("failure", () => throw TestFailure('oh no'));
test("error", () => throw 'oh no');
}
''').create();
Expand Down Expand Up @@ -103,13 +103,13 @@ import 'dart:async';
import 'package:test/test.dart';
Future main() {
return new Future(() {
return Future(() {
test("success", () {});
return new Future(() {
test("failure", () => throw new TestFailure('oh no'));
return Future(() {
test("failure", () => throw TestFailure('oh no'));
return new Future(() {
return Future(() {
test("error", () => throw 'oh no');
});
});
Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/test/runner/browser/phantom_js_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''').create();

Expand Down
32 changes: 16 additions & 16 deletions pkgs/test/test/runner/browser/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final _failure = '''
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''';

Expand Down Expand Up @@ -603,7 +603,7 @@ import 'package:test/test.dart';
void main() {
test("test", () {
if (p.style == p.Style.url) throw new TestFailure("oh no");
if (p.style == p.Style.url) throw TestFailure("oh no");
});
}
''').create();
Expand All @@ -622,7 +622,7 @@ import 'package:test/test.dart';
void main() {
test("test", () {
if (p.style != p.Style.url) throw new TestFailure("oh no");
if (p.style != p.Style.url) throw TestFailure("oh no");
});
}
''').create();
Expand Down Expand Up @@ -684,7 +684,7 @@ import 'package:test/test.dart';
void main() {
test("test", () {
print("Hello,");
return new Future(() => print("world!"));
return Future(() => print("world!"));
});
}
''').create();
Expand Down Expand Up @@ -727,7 +727,7 @@ import 'dart:async';
import 'package:test/test.dart';
void main() {
test("timeout", () => new Future.delayed(Duration.zero));
test("timeout", () => Future.delayed(Duration.zero));
}
''').create();

Expand All @@ -747,7 +747,7 @@ import 'dart:async';
import 'package:test/test.dart';
void main() {
test("fail", () => throw 'oh no', onPlatform: {"browser": new Skip()});
test("fail", () => throw 'oh no', onPlatform: {"browser": Skip()});
}
''').create();

Expand All @@ -763,7 +763,7 @@ import 'dart:async';
import 'package:test/test.dart';
void main() {
test("success", () {}, onPlatform: {"vm": new Skip()});
test("success", () {}, onPlatform: {"vm": Skip()});
}
''').create();

Expand All @@ -780,10 +780,10 @@ import 'package:test/test.dart';
void main() {
test("fail", () async {
await new Future.delayed(Duration.zero);
await Future.delayed(Duration.zero);
throw 'oh no';
}, onPlatform: {
"browser": new Timeout(Duration.zero)
"browser": Timeout(Duration.zero)
});
}
''').create();
Expand All @@ -804,7 +804,7 @@ import 'package:test/test.dart';
void main() {
test("success", () {}, onPlatform: {
"vm": new Timeout(new Duration(seconds: 0))
"vm": Timeout(Duration(seconds: 0))
});
}
''').create();
Expand All @@ -822,11 +822,11 @@ import 'package:test/test.dart';
void main() {
test("success", () {}, onPlatform: {
"browser": new Skip("first"),
"browser || windows": new Skip("second"),
"browser || linux": new Skip("third"),
"browser || mac-os": new Skip("fourth"),
"browser || android": new Skip("fifth")
"browser": Skip("first"),
"browser || windows": Skip("second"),
"browser || linux": Skip("third"),
"browser || mac-os": Skip("fourth"),
"browser || android": Skip("fifth")
});
}
''').create();
Expand Down Expand Up @@ -890,7 +890,7 @@ import 'package:test/test.dart';
void main() {
test("fail", () async {
await new Future.delayed(Duration.zero);
await Future.delayed(Duration.zero);
throw 'oh no';
});
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/test/runner/browser/safari_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("failure", () => throw new TestFailure("oh no"));
test("failure", () => throw TestFailure("oh no"));
}
''').create();

Expand Down
56 changes: 28 additions & 28 deletions pkgs/test/test/runner/compact_reporter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ void main() {

test('runs several failing tests and reports when each fails', () {
return _expectReport('''
test('failure 1', () => throw new TestFailure('oh no'));
test('failure 2', () => throw new TestFailure('oh no'));
test('failure 3', () => throw new TestFailure('oh no'));''', '''
test('failure 1', () => throw TestFailure('oh no'));
test('failure 2', () => throw TestFailure('oh no'));
test('failure 3', () => throw TestFailure('oh no'));''', '''
+0: loading test.dart
+0: failure 1
+0 -1: failure 1 [E]
Expand Down Expand Up @@ -82,9 +82,9 @@ void main() {

test('runs failing tests along with successful tests', () {
return _expectReport('''
test('failure 1', () => throw new TestFailure('oh no'));
test('failure 1', () => throw TestFailure('oh no'));
test('success 1', () {});
test('failure 2', () => throw new TestFailure('oh no'));
test('failure 2', () => throw TestFailure('oh no'));
test('success 2', () {});''', '''
+0: loading test.dart
+0: failure 1
Expand All @@ -110,34 +110,34 @@ void main() {
return _expectReport('''
// This completer ensures that the test isolate isn't killed until all
// errors have been thrown.
var completer = new Completer();
var completer = Completer();
test('failures', () {
new Future.microtask(() => throw 'first error');
new Future.microtask(() => throw 'second error');
new Future.microtask(() => throw 'third error');
new Future.microtask(completer.complete);
Future.microtask(() => throw 'first error');
Future.microtask(() => throw 'second error');
Future.microtask(() => throw 'third error');
Future.microtask(completer.complete);
});
test('wait', () => completer.future);''', '''
+0: loading test.dart
+0: failures
+0 -1: failures [E]
first error
test.dart 10:38 main.<fn>.<fn>
test.dart 10:34 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async new Future.microtask
test.dart 10:15 main.<fn>
test.dart 10:18 main.<fn>
second error
test.dart 11:38 main.<fn>.<fn>
test.dart 11:34 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async new Future.microtask
test.dart 11:15 main.<fn>
test.dart 11:18 main.<fn>
third error
test.dart 12:38 main.<fn>.<fn>
test.dart 12:34 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async new Future.microtask
test.dart 12:15 main.<fn>
test.dart 12:18 main.<fn>
+0 -1: wait
Expand All @@ -152,7 +152,7 @@ void main() {
'longer. Even more. We have to get to at least 200 characters. '
'I know that seems like a lot, but I believe in you. A little '
'more... okay, that should do it.',
() => throw new TestFailure('oh no'));''', '''
() => throw TestFailure('oh no'));''', '''
+0: loading test.dart
+0: really ... than that. No, yet longer. Even more. We have to get to at least 200 characters. I know that seems like a lot, but I believe in you. A little more... okay, that should do it.
+0 -1: really gosh dang long test name. Even longer than that. No, yet longer. Even more. We have to get to at least 200 characters. I know that seems like a lot, but I believe in you. A little more... okay, that should do it. [E]
Expand Down Expand Up @@ -187,15 +187,15 @@ void main() {
return _expectReport('''
// This completer ensures that the test isolate isn't killed until all
// prints have happened.
var testDone = new Completer();
var waitStarted = new Completer();
var testDone = Completer();
var waitStarted = Completer();
test('test', () {
waitStarted.future.then((_) {
new Future(() => print("one"));
new Future(() => print("two"));
new Future(() => print("three"));
new Future(() => print("four"));
new Future(testDone.complete);
Future(() => print("one"));
Future(() => print("two"));
Future(() => print("three"));
Future(() => print("four"));
Future(testDone.complete);
});
});
Expand All @@ -221,7 +221,7 @@ void main() {
return _expectReport('''
// This completer ensures that the test isolate isn't killed until all
// prints have happened.
var completer = new Completer();
var completer = Completer();
test('test', () {
scheduleMicrotask(() {
print("three");
Expand Down Expand Up @@ -287,7 +287,7 @@ void main() {
return _expectReport('''
test('slow', () async {
print('hello');
await new Future.delayed(new Duration(seconds: 3));
await Future.delayed(Duration(seconds: 3));
print('goodbye');
});''', '''
+0: loading test.dart
Expand Down Expand Up @@ -353,10 +353,10 @@ void main() {

test('runs skipped tests along with successful and failing tests', () {
return _expectReport('''
test('failure 1', () => throw new TestFailure('oh no'));
test('failure 1', () => throw TestFailure('oh no'));
test('skip 1', () {}, skip: true);
test('success 1', () {});
test('failure 2', () => throw new TestFailure('oh no'));
test('failure 2', () => throw TestFailure('oh no'));
test('skip 2', () {}, skip: true);
test('success 2', () {});''', '''
+0: loading test.dart
Expand Down
4 changes: 2 additions & 2 deletions pkgs/test/test/runner/configuration/platform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("test", () => new Future.delayed(Duration.zero));
test("test", () => Future.delayed(Duration.zero));
}
''').create();

Expand Down Expand Up @@ -61,7 +61,7 @@ void main() {
import 'package:test/test.dart';
void main() {
test("test", () => new Future.delayed(Duration.zero));
test("test", () => Future.delayed(Duration.zero));
}
''').create();

Expand Down
Loading

0 comments on commit dcd9b51

Please sign in to comment.