Skip to content

Commit

Permalink
Add support for optional tests for reverse string (#646)
Browse files Browse the repository at this point in the history
* Add support for optinal tests

* Add doc and improvments

* Update based on comments
  • Loading branch information
meatball133 authored Aug 10, 2024
1 parent dd1f89b commit ed9874a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
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

0 comments on commit ed9874a

Please sign in to comment.