Skip to content

Syncing test.toml and updating the test code for reverse-string #2648

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 6 commits into from
Jun 13, 2025

Conversation

jagdish-15
Copy link
Contributor

Pull Request

This PR syncs tests.toml with the problem-specifications repository and verifies the presence of new tests in the test file.

Copy link
Contributor

github-actions bot commented Jun 6, 2025

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

Copy link
Contributor

github-actions bot commented Jun 6, 2025

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Jun 6, 2025
@jagdish-15
Copy link
Contributor Author

This change introduces grapheme cluster & wide character handling to the exercise, which would require updating the proof solution accordingly. We had previously decided to skip such changes in the C track, see this PR for context. Could you please confirm if we’re moving forward with this change here?

@Cool-Katt Cool-Katt reopened this Jun 6, 2025
@Cool-Katt
Copy link
Contributor

Well ,there is a way to work with graphemes in JS, but most of the default behaviour doesn't account for it so if we add these tests I can guarantee you that almost all the current solution will fail.
Do we expect students to be able to deal with such weirdness at the level that this exercise is? If we do end up adding the tests it'll probably be good to also amend the instructions with some sort of explanation. @SleeplessByte opinions?


I had to deal with this in micro-blog and i wrote up an entire Dig Deeper section about it, so maybe check that if you want to know more of the technical angle.

@SleeplessByte
Copy link
Member

I haven't looked at the current proof. Is this updating from .split('') to [...x] / Array.from(x)?

If yes, we should do this. People shouldn't split into characters like the first one anyway. If no, and it is harder, we can decide between not including or making them optional. We have a special flag and syntax to allow for that.

@jagdish-15
Copy link
Contributor Author

I'll look into it this Monday or Tuesday!

@SleeplessByte SleeplessByte added x:action/sync Sync content with its latest version x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) labels Jun 10, 2025
@jagdish-15
Copy link
Contributor Author

I got it running after checking out the Intl.Segmenter object from the Dig Deeper section by @Cool-Katt!

Do we expect students to be able to deal with such weirdness at the level that this exercise is? If we do end up adding the tests it'll probably be good to also amend the instructions with some sort of explanation.

Now that's a topic of discussion. What do you think @SleeplessByte @Cool-Katt

@jagdish-15
Copy link
Contributor Author

Since this is a practice exercise, I think it’s totally fine to include these tests. If we decide to go ahead, we’ll just need to add an instructions.append.md file and update the difficulty from Easy to Medium.

Alternatively, we can always choose to skip the tests.
Let me know what you think!

@SleeplessByte
Copy link
Member

Can you try if let characters = [...string] works ?

@Cool-Katt
Copy link
Contributor

Cool-Katt commented Jun 11, 2025

Well, I checked the current solutions and I don't really know how many total submissions there are, but exactly two of them use Intl.Segmenter, and one of the two is kinda "cheety" by using .reverse() directly, so I can tell you that this change will cause some confusion.

This discussion may need to happen on the forum to get more voices on the matter, so feel free to open a thread and link this PR there @jagdish-15. Presonaly, I'm tentatively for a merge and bumping the difficulty.

@Cool-Katt
Copy link
Contributor

@SleeplessByte If you mean something like this:

const expected = 'dnatsnehctsrüW';
const actual = 'Würstchenstand';
console.log([...actual].reverse().join('').localeCompare(expected))
// => 1 (not the same)

This definitely doesn't work, in the test with 'Würstchenstand', it puts the umlaut (the two dots on top of the 'u') on the 'r' instead, which is also frustrating because it visually is hard to tell the difference.

@SleeplessByte
Copy link
Member

Ok perfect.

I dont think we should make this exercise more difficult. I rather have an exercise that goes further exploring this concept.

@Cool-Katt
Copy link
Contributor

We do (kind of)! micro-blog is dealing with this weirdness.

I'm okay with not complicating things more for this exercise, as it is a more beginner friendly exercise.

@SleeplessByte
Copy link
Member

We do (kind of)! micro-blog is dealing with this weirdness.

I'm okay with not complicating things more for this exercise, as it is a more beginner friendly exercise.

Ah yeah, I remember that one!

@jagdish-15 can you remove the tests that require the segmenter?

@jagdish-15
Copy link
Contributor Author

jagdish-15 commented Jun 11, 2025

Can you try if let characters = [...string] works ?

I did try it, but it didn't work, as @Cool-Katt showed

@jagdish-15 can you remove the tests that require the segmenter?

Should I remove it altogether or skip them using test.skip(...)?

@SleeplessByte
Copy link
Member

Should I remove it altogether or skip them using test.skip(...)?

Oh right. We have that option. I guess we can add a track insert (instruction addendum):

~~~exercism/advanced
If you solve this using the CLI, there are test cases that require you to deal with complex characters.
You can optionally enable these tests by removing `.skip` from the test.
~~~

@Cool-Katt what do you think?

@jagdish-15
Copy link
Contributor Author

jagdish-15 commented Jun 12, 2025

I guess we can add a track insert (instruction addendum):

I vaguely remember seeing something similar already implemented in another exercise. In that case, comments were added above the skipped tests to inform CLI users that the tests are skipped by default (since most solutions would time out), but they can enable them manually if they want to experiment.

So I think staying consistent with that approach would be a good idea! But we'll see what @Cool-Katt says

@Cool-Katt
Copy link
Contributor

Yep, I agree with skip and an addendum.

@jagdish-15
Copy link
Contributor Author

jagdish-15 commented Jun 12, 2025

I was discussing this exercise, pythagorean-triplet test file. It has skipped tests, but there is no addendum referring to that. Should we append instructions there as well, to address the skipped tests?

@Cool-Katt
Copy link
Contributor

Yep.
People rarely ever read the test file separately so I feel that the note that DJ suggested is good to include.

@jagdish-15
Copy link
Contributor Author

I've added the part suggested by @SleeplessByte and raised another PR (#2671) to do something similar for the reverse-string exercise. @Cool-Katt and @SleeplessByte take a look and lemme know if it works!

Comment on lines +41 to +45
xtest('wide characters', () => {
const expected = '猫子';
const actual = reverseString('子猫');
expect(actual).toEqual(expected);
});
Copy link
Member

Choose a reason for hiding this comment

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

This one passes with the previous solution? If yes, this is good, if no it also needs to be skipped :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does indeed pass with the previous solution (I remember it did pass with [...string]) but I'll still check it once again to be sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the old solution passes the test as well, so there’s no need to skip it.
By the way, should we stick with the segmenter solution or revert to the original?
I think keeping the segmenter version is a better choice, especially since it also passes the skipped tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

The proof solution is more for the CI, to prove that the tests can be passed, so the segmenter version can stay.

Copy link
Member

@SleeplessByte SleeplessByte left a comment

Choose a reason for hiding this comment

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

See one comment

@Cool-Katt Cool-Katt merged commit 2d66526 into exercism:main Jun 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/sync Sync content with its latest version x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants