-
Notifications
You must be signed in to change notification settings - Fork 675
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
Tests for samples #453
Tests for samples #453
Conversation
{% prettify dart %} | ||
// Importing core libraries | ||
import 'dart:async'; | ||
import 'dart:math'; | ||
|
||
// Importing libraries from external packages | ||
import 'package:angular2/angular2.dart'; | ||
import 'package:test/test.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that external package would do and so went with test
. Avoiding angular here means that we avoid the delays on precompiling it when pub get/upgrade
is run.
db42d76
to
8d6d2a8
Compare
src/_samples/index.md
Outdated
class Probe extends Spacecraft with Describable { | ||
Probe(String name) : super(name, new DateTime.now()); | ||
} | ||
{% endprettify %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added example of the use of the abstract class, though as a mixin. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @filiph what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this alone helps explain how this works. If we're adding sample code, I'd suggest adding:
var probe = new Probe("probe"); // TODO(chalin): some better name
probe.describeWithEmphasis(); // Method taken from the Describable class.
Also not sure whether introducing a mixin in the example is a good idea. It might be confusing that we're suddenly showing a mixin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then I'll just pull that out.
8d6d2a8
to
782a216
Compare
17b2a7f
to
48a1789
Compare
src/_samples/index.md
Outdated
{% prettify dart %} | ||
class Manned { | ||
int astronauts; | ||
class Piloted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change!
src/_samples/index.md
Outdated
{% prettify dart %} | ||
class MockSpaceship implements Spacecraft { | ||
// ... | ||
// ··· |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed the changes from ...
to ···
. It looks strange to me because of the vertical alignment—like you're showing single-quote characters, rather than an ellipsis (which I expect to look like [or be] three periods).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, you are right. Ok, I'll have to make a sweeping change of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted to using dots in the samples code. I'll address other instances separately.
src/_samples/index.md
Outdated
@@ -252,26 +268,37 @@ abstract class Describable { | |||
} | |||
{% endprettify %} | |||
|
|||
Any class extending `Describable` has the `describeWithEmphasis()` method, which calls the extender's implementation of `describe()`. | |||
Any class extending `Describable` or using it as a mixin has the `describeWithEmphasis()` method, which calls the extender's / base class implementation of `describe()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extender's / base class
->
extender or base class
(I usually avoid "/" in text, since it can be ambiguous. https://developers.google.com/style/slashes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Since the mixin has been dropped, I've reverted to the original sentence.)
src/_samples/index.md
Outdated
class Probe extends Spacecraft with Describable { | ||
Probe(String name) : super(name, new DateTime.now()); | ||
} | ||
{% endprettify %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @filiph what do you think?
src/_samples/index.md
Outdated
const aSecond = const Duration(seconds: 1); | ||
// ··· | ||
Future<Null> printWithDelay(String message) [!async!] { | ||
await new Future.delayed(aSecond); | ||
print(message); | ||
} | ||
{% endprettify %} | ||
|
||
The code above is equivalent to: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code -> method
(because you added the code for const aSecond)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
src/_samples/index.md
Outdated
{% prettify dart %} | ||
Future<Null> printWithDelay(String message) async { | ||
await new Future.delayed(const Duration(seconds: 1)); | ||
const aSecond = const Duration(seconds: 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep reading "aSecond" as "a second [something]", so maybe:
aSecond
-> oneSecond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
48a1789
to
52bb0e9
Compare
Contributes to #407
52bb0e9
to
614dadb
Compare
Post-review edits done. Kathy gave a 👍 to merging, so here goes ... |
Contributes to #407
Staged at: https://dartlang-org-staging-0.firebaseapp.com/samples