-
-
Notifications
You must be signed in to change notification settings - Fork 60
Add spec generator for acronym #635
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
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
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,23 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Runs tests for all provided slugs | ||
|
|
||
| RESULT=0 | ||
|
|
||
| rm -rf test-exercises | ||
| cp -r exercises/practice test-exercises | ||
| cd test-exercises || exit 1 | ||
|
|
||
| for i in "$@" | ||
| do | ||
| if test -d "$i" | ||
| then | ||
| echo "Testing $i..." | ||
| pushd "$i" | ||
| mv .meta/example.lua "$i.lua" | ||
| busted --verbose || RESULT=1 | ||
| popd | ||
| fi | ||
| done | ||
|
|
||
| exit $RESULT |
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,11 @@ | ||
| return { | ||
| module_name = 'acronym', | ||
|
|
||
| generate_test = function(case) | ||
| local template = [[ | ||
| local input = "%s" | ||
| local expected = '%s' | ||
| assert.equal(expected, acronym(input))]] | ||
| return template:format(case.input.phrase, case.expected) | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,57 @@ | ||
| local acronym = require('acronym') | ||
|
|
||
| describe('acronym', function() | ||
| it('should generate single-letter acronyms', function() | ||
| assert.equal('L', acronym('Lua')) | ||
| it('basic', function() | ||
| local input = "Portable Network Graphics" | ||
| local expected = 'PNG' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('should generate multi-letter acronyms', function() | ||
| assert.equal('LUA', acronym('Lua Ultimate Acronym')) | ||
| it('lowercase words', function() | ||
| local input = "Ruby on Rails" | ||
| local expected = 'ROR' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('should include lowercase words', function() | ||
| assert.equal('ROR', acronym('Ruby on Rails')) | ||
| it('punctuation', function() | ||
| local input = "First In, First Out" | ||
| local expected = 'FIFO' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('should ignore punctuation', function() | ||
| assert.equal('FIFO', acronym('First In, First Out')) | ||
| it('all caps word', function() | ||
| local input = "GNU Image Manipulation Program" | ||
| local expected = 'GIMP' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('should split words with internal capitalization', function() | ||
| assert.equal('HTML', acronym('HyperText Markup Language')) | ||
| it('punctuation without whitespace', function() | ||
| local input = "Complementary metal-oxide semiconductor" | ||
| local expected = 'CMOS' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('should not split words that are all uppercase', function() | ||
| assert.equal('PHP', acronym('PHP: Hypertext Processor')) | ||
| it('very long abbreviation', function() | ||
| local input = "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" | ||
| local expected = 'ROTFLSHTMDCOALM' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('consecutive delimiters', function() | ||
| local input = "Something - I made up from thin air" | ||
| local expected = 'SIMUFTA' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('apostrophes', function() | ||
| local input = "Halley's Comet" | ||
| local expected = 'HC' | ||
| assert.equal(expected, acronym(input)) | ||
| end) | ||
|
|
||
| it('underscore emphasis', function() | ||
| local input = "The Road _Not_ Taken" | ||
| local expected = 'TRNT' | ||
| assert.equal(expected, acronym(input)) | ||
| 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.
This makes it easier to test just one or a small number of exercises