-
Notifications
You must be signed in to change notification settings - Fork 1
Created an instance of Arbitrary[String] #13
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
base: master
Are you sure you want to change the base?
Created an instance of Arbitrary[String] #13
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13 +/- ##
==========================================
- Coverage 83.33% 62.5% -20.84%
==========================================
Files 1 1
Lines 6 8 +2
==========================================
Hits 5 5
- Misses 1 3 +2
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(",")) | ||
| // println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(",")) |
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.
Remove this commented line
DanielaSfregola
left a comment
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.
Hi @KXA194,
thanks for your contribution! This is a good start: you are generating arbitrary correctly.
Could you please have a look at addressing my comments?
Thanks,
Daniela
| println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(",")) | ||
| // println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(",")) | ||
|
|
||
| val words: Set[String] = extractUniqueWordsFromTextFile("BaconipSum.txt") |
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.
Although this is correct, you should change this so that the file name is given rather than fixed.
Maybe, you could create a class that given a text file, gives you an Arbitrary[String] based on the words in the given file. Your class should also handle corner cases. For example, what would happen if the given file does not exist?
Cheers,
Daniela
| // println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(",")) | ||
|
|
||
| val words: Set[String] = extractUniqueWordsFromTextFile("BaconipSum.txt") | ||
| val word: Arbitrary[String] = Arbitrary { |
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.
Well done! You can also just write Arbitrary(Gen.oneOf(words)) - it's the same, just more compact!
An arbitrary word is selected from a textfile.