-
-
Notifications
You must be signed in to change notification settings - Fork 525
pig-latin: generate tests using canonical data #563
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
Conversation
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.
Looks good.
My nitpicks are pretty minor things.
exercises/pig-latin/example.tt
Outdated
require_relative 'pig_latin' | ||
|
||
# Common test data version: <%= abbreviated_commit_hash %> | ||
class PigLatinTest < Minitest::Test<% test_cases.each do |test_case| %> |
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.
Add a newline here to split the class definition from the template code.
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.
Blech. ERB. Adding a newline here causes formatting problems in the generated test file.
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.
I believe you can use a backslash to avoid that? There is also something in ERB itself that lets you ignore the new line.
Minor thing though though.
The generated file being exemplar is more important.
lib/pig_latin_cases.rb
Outdated
JSON.parse(data)['cases']. | ||
flat_map {|section| section['cases'] }. | ||
each_with_index. | ||
reduce([]) {|cases, (test, i)| cases << PigLatinCase.new(test.merge('index' => i)) } |
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.
This is a bit of a mega code pipeline.
I wonder is it possible to add some intention revealing variable names into the mix.
Thank you @hilary ! |
Description
Motivation and Context
How Has This Been Tested?
rake test