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

Add support for optional tests for reverse string #646

Merged
merged 3 commits into from
Aug 10, 2024
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 @@
# Instructions append

An optional test has been added that tests for possible letters to be any unicode character, not just ASCII alphabetic ones.
These are not accessible from the web editor, but are run by default when executed locally.

To disable these tests, when calling the test command (`crystal spec`), add the following flag: `--tag "~optional"`
8 changes: 6 additions & 2 deletions exercises/practice/reverse-string/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ require "../src/*"

describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["value"] %>").should eq("<%= cases["expected"] %>")
<%- if cases["scenarios"]? %>
<%= status()%> "<%-= cases["description"] %>", tags: "optional" do
<%- else %>
<%= status()%> "<%-= cases["description"] %>" do
<%- end %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["value"] %>").should eq("<%= cases["expected"] %>")
end
<% end %>
end
3 changes: 0 additions & 3 deletions exercises/practice/reverse-string/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ description = "an even-sized word"

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

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

[1028b2c1-6763-4459-8540-2da47ca512d9]
description = "grapheme clusters"
include = false
12 changes: 12 additions & 0 deletions exercises/practice/reverse-string/spec/reverse_string_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,16 @@ describe "ReverseString" do
pending "an even-sized word" do
ReverseString.reverse("drawer").should eq("reward")
end

pending "wide characters", tags: "optional" do
ReverseString.reverse("子猫").should eq("猫子")
end

pending "grapheme cluster with pre-combined form", tags: "optional" do
ReverseString.reverse("Würstchenstand").should eq("dnatsnehctsrüW")
end

pending "grapheme clusters", tags: "optional" do
ReverseString.reverse("ผู้เขียนโปรแกรม").should eq("มรกแรปโนยขีเผู้")
end
end