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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- prettier-ignore-start -->
~~~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.
~~~
<!-- prettier-ignore-end -->
1 change: 1 addition & 0 deletions exercises/practice/reverse-string/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"contributors": [
"ankorGH",
"d-vail",
"jagdish-15",
"ovidiu141",
"SleeplessByte"
],
Expand Down
8 changes: 6 additions & 2 deletions exercises/practice/reverse-string/.meta/proof.ci.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
export const reverseString = (string) => {
let revString = '';
for (let i = string.length - 1; i >= 0; i -= 1) {
revString += string[i];
let characters = Array.from(
new Intl.Segmenter().segment(String(string)),
(x) => x.segment,
);
for (let i = characters.length - 1; i >= 0; i--) {
revString += characters[i];
}
return revString;
};
22 changes: 19 additions & 3 deletions exercises/practice/reverse-string/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[c3b7d806-dced-49ee-8543-933fd1719b1c]
description = "an empty string"
Expand All @@ -19,3 +26,12 @@ description = "a palindrome"

[b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c]
description = "an even-sized word"

[1bed0f8a-13b0-4bd3-9d59-3d0593326fa2]
description = "wide characters"

[93d7e1b8-f60f-4f3c-9559-4056e10d2ead]
description = "grapheme cluster with pre-combined form"

[1028b2c1-6763-4459-8540-2da47ca512d9]
description = "grapheme clusters"
18 changes: 18 additions & 0 deletions exercises/practice/reverse-string/reverse-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,22 @@ describe('ReverseString', () => {
const actual = reverseString('drawer');
expect(actual).toEqual(expected);
});

xtest('wide characters', () => {
const expected = '猫子';
const actual = reverseString('子猫');
expect(actual).toEqual(expected);
});
Comment on lines +41 to +45
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.


test.skip('grapheme cluster with pre-combined form', () => {
const expected = 'dnatsnehctsrüW';
const actual = reverseString('Würstchenstand');
expect(actual).toEqual(expected);
});

test.skip('grapheme clusters', () => {
const expected = 'มรกแรปโนยขีเผู้';
const actual = reverseString('ผู้เขียนโปรแกรม');
expect(actual).toEqual(expected);
});
});