Skip to content

#3180. Add more js_interop tests #3232

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

Merged
merged 2 commits into from
Jun 19, 2025

Conversation

sgrekhov
Copy link
Contributor

No description provided.

Copy link

@srujzs srujzs left a comment

Choose a reason for hiding this comment

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

LGTM % some nits!

// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion An opaque reference to a Dart object that can be passed to
Copy link

Choose a reason for hiding this comment

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

nit: Do we need to copy the documentation here and elsewhere? If it ever changes this might become stale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is our usual approach. While the documentation may occasionally become outdated, it can also indicate that the corresponding test needs to be revised. Let's keep it for now.

}
''');
if (isWasm) {
ExternalDartReference<C> jsC = getCfromJS();
Copy link

@srujzs srujzs Jun 18, 2025

Choose a reason for hiding this comment

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

You can't really test it because it traps (I think), but worth leaving a comment that if you did toDartObject, this would error on dart2wasm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment added.

}

@JS()
external ExternalDartReference<C> getCfromJS();
Copy link

Choose a reason for hiding this comment

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

We already have tests for this in the SDK, but you could try ExternalDartReference<C?> and ExternalDartReference<C>? variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nullable variants added.


/// @assertion A JavaScript `BigInt`
///
/// @description Check that `JSBigInt` can store big integer values (more that
Copy link

Choose a reason for hiding this comment

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

nit: than

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor Author

@sgrekhov sgrekhov left a comment

Choose a reason for hiding this comment

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

Thank you! Updated. PTAL.

// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion An opaque reference to a Dart object that can be passed to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is our usual approach. While the documentation may occasionally become outdated, it can also indicate that the corresponding test needs to be revised. Let's keep it for now.

}
''');
if (isWasm) {
ExternalDartReference<C> jsC = getCfromJS();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment added.


/// @assertion A JavaScript `BigInt`
///
/// @description Check that `JSBigInt` can store big integer values (more that
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}

@JS()
external ExternalDartReference<C> getCfromJS();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nullable variants added.

@sgrekhov sgrekhov requested a review from srujzs June 19, 2025 07:21
@chloestefantsova chloestefantsova merged commit 4d428cb into dart-lang:master Jun 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants