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

Ensure Try-Dart example sources are analyzed and tested #2124

Merged
merged 5 commits into from
Nov 25, 2019

Conversation

chalin
Copy link
Contributor

@chalin chalin commented Nov 20, 2019

Staged, see:

cc @mit-mit

@chalin chalin added fix.examples Adds or changes example test.general Relates to unit, integration, perf testing ⚠ WIP infra.dartpad Relates to DartPad component code or functionality labels Nov 20, 2019
@googlebot googlebot added the cla: yes Contributor has signed the Contributor License Agreement label Nov 20, 2019
@mit-mit
Copy link
Member

mit-mit commented Nov 21, 2019

I'd really prefer to not introduce a second page with DartPad on it. That would leave us with three places: 1) landing page, 2) try-dart page, 3) dartpad.dev.

My idea was to add some more white space around the dartpad embed on the landing page so it seems more focused. Checkout this demo:
https://mit-staging.firebaseapp.com/#try-dart

Note that it currently is broken in the mobile/narrow view, I left a TODO, should be easy to fix (?) for someone who unlike me actually knows html & css.

Mock implementation: mit-mit@77310ed

@chalin
Copy link
Contributor Author

chalin commented Nov 21, 2019

I'd really prefer to not introduce a second page with DartPad on it. ...

I've removed the trial /try-dart page.

My idea was to add some more white space around the dartpad embed ...

I've created #2127 to track this and offer a place for discussion in case @galeyang et all might want to offer some advice.

Staging server refreshed with most recent changes.

@chalin
Copy link
Contributor Author

chalin commented Nov 21, 2019

Btw, the current approach always loads the try-dart example sources (because the sources are embedded in the homepage). If you believe that that is too inefficient for mobile (where we don't show the embedded DartPad), then I can move the try-dart example sources to another page that is only conditionally fetched. Of course there are tradeoffs to having the sources on another page, since that other page might fail to load -- not a situation that we need to deal with in the current approach.

@chalin chalin changed the title [WIP] Ensure Try-Dart example sources are analyzed and tested Ensure Try-Dart example sources are analyzed and tested Nov 21, 2019
@chalin chalin removed the ⚠ WIP label Nov 21, 2019

// Classes can extend other classes.
class DiamondSword extends Sword {
int damage = 50; // ignore: overridden_fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's instead change the damage field to a getter to make this warning go away

// Functions are objects.
int runTwice(int x, Function f) {
for (var i = 0; i < 2; i++) {
x = f(x); // ignore: invalid_assignment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would using a local variable make this warning go away?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but giving f the type of int Function(int) works.

return x;
}

// ignore: type_annotate_public_apis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make the return type void instead.

return evenNumbers;
}

// ignore: type_annotate_public_apis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, let's make the return type void.

'Glass',
};

main() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need a void return type to pass analysis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to drop the ignore directive in line 1, then yes.

int timesFour(int x) => timesTwo(timesTwo(x));

// Functions are objects.
int runTwice(int x, Function f) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change from int Function(int) f?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It currently is Function f on dart.dev. I changed it to int Function(int) f in the first commit to this PR, and then reverted the change so that we could separately discuss and address any required code changes in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, no problem.

@chalin
Copy link
Contributor Author

chalin commented Nov 25, 2019

@johnpryan - aside from the examples sources, any feedback on the changes to the other files -- including tool/dartpad_picker/lib/dartpad_picker.dart?

),
);

String /*?*/ _getSrc(HtmlElement root, String id, [String fallback]) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the /*?*/ do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for catching that. The function originally returned a nullable String, but it doesn't anymore. (I use /*?*/ to mark types as nullable, until we can use the ? syntax for real :)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed comment.

@chalin
Copy link
Contributor Author

chalin commented Nov 25, 2019

Travis is green, merging. Followup changes will be tracked via #2126.

@chalin chalin merged commit b2acb0b into master Nov 25, 2019
@chalin chalin deleted the chalin-homepage-src-1115 branch November 25, 2019 19:16
@johnpryan johnpryan mentioned this pull request Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Contributor has signed the Contributor License Agreement fix.examples Adds or changes example infra.dartpad Relates to DartPad component code or functionality test.general Relates to unit, integration, perf testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support loading DartPad sources from site vs Gist
4 participants