This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am longmuir on github. | |
* I am jamielongmuir (https://keybase.io/jamielongmuir) on keybase. | |
* I have a public key whose fingerprint is A874 2759 6319 3818 A5D7 86FF 0C6B 7F09 F1EF 9464 | |
To claim this, I am signing this object: |
This file contains 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
import org.scalatest.WordSpec | |
import org.scalatest.prop.GeneratorDrivenPropertyChecks | |
import org.scalacheck.Gen | |
//Simplified case classes with companion objects and function definitions omitted for brevity | |
case class City(name: String) | |
case class Flight(number: Int, origin: City, dest: City, aircraft: Aircraft) | |
case class Aircraft(name: String, range: Int) | |
class FlightSpec extends WordSpec with GeneratorDrivenPropertyChecks { |
This file contains 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
val smallEvenInteger = Gen.choose(0,200) suchThat (_ % 2 == 0) | |
val propMakeList = forAll { n: Int => | |
(n >= 0 && n < 10000) ==> (List.fill(n)("").length == n) | |
} |
This file contains 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
case class Customer(name: String, number: Int) | |
val customerGen:Gen[Customer] = for { | |
name <- Gen.oneOf("Bob", "Larry", "Ed", "Ted") //Could also be a custom name generator | |
number <- Gen.posNum[Int] | |
} yield Customer(name, number) |
This file contains 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
property("delete only element should yield empty") = forAll { a: A => | |
val queue = insert(a, queue) //returns a new queue with ‘a’ added to ‘empty’ | |
deleteMin(queue) == empty | |
} |
This file contains 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
property("size of 2 super lists combined, should be equal to the sum of the size of the inputs") = { | |
forAll { (a: SuperList[A], b: SuperList[A]) => | |
val expectedSum = a.size + b.size | |
(a ++ b).size == expectedSum | |
} | |
} |
This file contains 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
GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation. | |
(DemoCheck.scala:40) | |
Falsified after 4 successful property evaluations. | |
Location: (DemoCheck.scala:40) | |
Occurred when passed generated values ( | |
arg0 = -1 // 30 shrinks | |
) |
This file contains 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
property("Square root of integer should be less or equal to the input value") = { | |
forAll { (inputValue: Int) => | |
Math.sqrt(inputValue) <= inputValue | |
} | |
} |
This file contains 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
test("Square root of 16 is 4") { | |
assert(Math.sqrt(16) == 4) | |
} |