Skip to content
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

Created an instance of Arbitrary[String] #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kxa14
Copy link
Contributor

@kxa14 kxa14 commented Feb 22, 2020

An arbitrary word is selected from a textfile.

@codecov
Copy link

codecov bot commented Feb 22, 2020

Codecov Report

Merging #13 into master will decrease coverage by 20.83%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...cala/com/danielasfregola/zucchini/Dictionary.scala 62.5% <0%> (-20.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 835c2b5...892a756. Read the comment docs.

@@ -16,6 +18,10 @@ object Dictionary extends App {
texts.flatMap(line => line.split("\\W+"))
}

println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(","))
// println(extractUniqueWordsFromTextFile("BaconipSum.txt").mkString(","))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this commented line

Copy link
Owner

@DanielaSfregola DanielaSfregola left a 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


val words: Set[String] = extractUniqueWordsFromTextFile("BaconipSum.txt")
Copy link
Owner

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


val words: Set[String] = extractUniqueWordsFromTextFile("BaconipSum.txt")
val word: Arbitrary[String] = Arbitrary {
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants