Skip to content

[intl4x] Add randomized equivalence test for NumberFormat constructors - #1118

Open
mosuem wants to merge 1 commit into
intl4x-fix-currency-fraction-digitsfrom
intl4x-number-format-equivalence-test
Open

mosuem wants to merge 1 commit into
intl4x-fix-currency-fraction-digitsfrom
intl4x-number-format-equivalence-test

Conversation

@mosuem

@mosuem mosuem commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Note

This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.

Adds test/number_format_equivalence_test.dart. It checks that NumberFormat.percent, NumberFormat.compact and NumberFormat.currency format exactly like the general NumberFormat constructor with the equivalent style or notation, for 300 random option combinations each, and that no combination throws.

The random options cover every parameter of these constructors: locale, sign display, notation, grouping, numbering system, rounding mode, trailing zero display, minimum integer digits, fraction and significant digits (with rounding priority), currency display and sign, and the style for compact. The seed is fixed, so results are reproducible, and a failure lists the first failing combinations.

The test would have caught both bugs fixed earlier in this stack:

Like the other tests for these constructors, it only runs on web (the group is tagged icu4xUnimplemented), because they are not implemented on native yet.

Verified locally: dart analyze --fatal-infos, dart format --output=none --set-exit-if-changed ., dart test -p node -x ecmaUnsupported, dart test -p node -c dart2wasm on the number format tests, and dart test on the number format tests (VM, where the new tests are skipped) pass. The new tests take well under a second.

@mosuem
mosuem added this pull request to stack #1119 October 30, 2026 07:26
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a randomized testing suite for the intl4x package to verify that specialized NumberFormat convenience constructors behave identically to the general constructor when provided with equivalent configurations. This approach helps ensure consistency across the API and proactively identifies edge cases or errors in formatting logic.

Highlights

  • New Randomized Equivalence Test: Added a new test file that performs randomized equivalence checks between convenience NumberFormat constructors (percent, compact, currency) and the general NumberFormat constructor.
  • Robustness and Reproducibility: The test uses a fixed seed for reproducibility and covers 300 random option combinations per constructor to ensure consistency and catch potential regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
intl4x None 1.0.1 1.0.2-wip 1.0.2-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Coverage ✔️
File Coverage

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// 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.
Files
no missing headers

All source files should start with a license header.

This check can be disabled by tagging the PR with skip-license-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Unused Dependencies ✔️
Package Status
intl4x ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new test file number_format_equivalence_test.dart to verify that the convenience constructors of NumberFormat (percent, compact, and currency) behave identically to the general NumberFormat constructor when configured with equivalent options. The reviewer suggests exporting NumberingSystem from package:intl4x/number_format.dart in a future change, as it is currently imported from datetime_format.dart but used in NumberFormat constructors.


import 'dart:math';

import 'package:intl4x/datetime_format.dart' show NumberingSystem;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It looks like NumberingSystem is imported from package:intl4x/datetime_format.dart because it is not currently exported by package:intl4x/number_format.dart. Since NumberFormat accepts NumberingSystem? numberingSystem in its constructors, NumberingSystem should ideally be exported by package:intl4x/number_format.dart to make the API more cohesive and discoverable for users. Consider exporting NumberingSystem in pkgs/intl4x/lib/number_format.dart in a follow-up change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please fix


import 'dart:math';

import 'package:intl4x/datetime_format.dart' show NumberingSystem;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please fix

Checks that NumberFormat.percent, NumberFormat.compact and
NumberFormat.currency format exactly like the general NumberFormat
constructor with the equivalent style or notation, for random option
combinations with a fixed seed, and that no combination throws.

It catches both the dropped digits in NumberFormat.percent and the
currency fraction digits error fixed earlier in this stack.
@mosuem
mosuem force-pushed the intl4x-number-format-equivalence-test branch from 7967728 to 5991ed8 Compare October 31, 2026 01:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants