-
-
Notifications
You must be signed in to change notification settings - Fork 528
Add templates for exercises batch 6 #1786
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
Open
meatball133
wants to merge
2
commits into
main
Choose a base branch
from
add-template-batch6
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
exercises/practice/largest-series-product/.meta/test_template.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'minitest/autorun' | ||
require_relative 'largest_series_product' | ||
|
||
class LargestSeriesProductTest < Minitest::Test | ||
<% json["cases"].each do |cases| %> | ||
def test_<%= underscore(cases["description"]) %> | ||
<%= skip? %> | ||
<%- if cases["expected"].is_a?(Hash) && cases["expected"].key?("error") -%> | ||
assert_raises(ArgumentError) do | ||
Series.new('<%= cases["input"]["digits"] %>').largest_product(<%= cases["input"]["span"] %>) | ||
end | ||
<%- else -%> | ||
assert_equal <%= cases["expected"] %>, Series.new('<%= cases["input"]["digits"] %>').largest_product(<%= cases["input"]["span"] %>) | ||
<%- end -%> | ||
end | ||
<% end %> | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'minitest/autorun' | ||
require_relative 'leap' | ||
|
||
class Date | ||
def leap? | ||
raise "Implement this yourself instead of using Ruby's implementation." | ||
end | ||
|
||
alias gregorian_leap? leap? | ||
alias julian_leap? leap? | ||
end | ||
|
||
class YearTest < Minitest::Test | ||
<% json["cases"].each do |cases| %> | ||
def test_<%= underscore(cases["description"]) %> | ||
<%= skip? %> | ||
<%= cases["expected"] ? "assert" : "refute" %> Year.leap?(<%= cases["input"]["year"] %>), "Expected '<%= cases["expected"] %>', <%= cases["input"]["year"] %> is<%= cases["expected"] ? "" : " not" %> a leap year" | ||
end | ||
<% end %> | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'minitest/autorun' | ||
require_relative 'linked_list' | ||
|
||
class DequeTest < Minitest::Test | ||
<% json["cases"].each do |cases| %> | ||
def test_<%= underscore(cases["description"]) %> | ||
#<%= skip? %> | ||
deque = Deque.new | ||
<%- cases["input"]["operations"].each do |operation| -%> | ||
<%- if operation["expected"] -%> | ||
assert_equal <%= operation["expected"] %>, deque.<%= operation["operation"] %>(<%= operation["value"] %>) | ||
<%- else -%> | ||
deque.<%= operation["operation"] %>(<%= operation["value"] %>) | ||
<%- end -%> | ||
<%- end -%> | ||
end | ||
<% end %> | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because "implement the implement you implement yourself, rather than the implement that Ruby implements" can be very confusing, if accurate and proper use, but I tend to avoid this word in multicultural and multilingual audiences.
English is hard enough as it is, using a word with 4 senses when people tend to not take care or be clear which sense they are talking about can be doubly hard for those that do not have English as a first language.