-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8860268
commit 17f3767
Showing
11 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
38 changes: 38 additions & 0 deletions
38
indigo/indigo/src/test/scala/indigo/shared/datatypes/PointSpecification.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package indigo.shared.datatypes | ||
|
||
import indigo.shared.dice.Dice | ||
import org.scalacheck._ | ||
|
||
class PointSpecification extends Properties("Dice") { | ||
|
||
property("all random values are within the max range and >= 0") = Prop.forAll(Gen.choose(0, 500)) { max => | ||
val dice = Dice.fromSeed(0) | ||
val value = Point.random(dice, max) | ||
|
||
value.x >= 0 && value.y >= 0 && value.x <= max && value.y <= max | ||
} | ||
|
||
property("all random values are within the max range (Point) and >= 0") = Prop.forAll(Gen.choose(0, 500)) { max => | ||
val dice = Dice.fromSeed(0) | ||
val value = Point.random(dice, Point(max)) | ||
|
||
value.x >= 0 && value.y >= 0 && value.x <= Point(max).x && value.y <= Point(max).y | ||
} | ||
|
||
property("all random values are within the min / max range") = Prop.forAll(Gen.choose(-500, 0), Gen.choose(0, 500)) { | ||
(min, max) => | ||
val dice = Dice.fromSeed(0) | ||
val value = Point.random(dice, min, max) | ||
|
||
value.x >= min && value.y >= min && value.x <= max && value.y <= max | ||
} | ||
|
||
property("all random values are within the min / max range (Point)") = Prop.forAll(Gen.choose(-500, 0), Gen.choose(0, 500)) { | ||
(min, max) => | ||
val dice = Dice.fromSeed(0) | ||
val value = Point.random(dice, Point(min), Point(max)) | ||
|
||
value.x >= Point(min).x && value.y >= Point(min).y && value.x <= Point(max).x && value.y <= Point(max).y | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
indigo/indigo/src/test/scala/indigo/shared/datatypes/RadiansSpecification.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package indigo.shared.datatypes | ||
|
||
import indigo.shared.dice.Dice | ||
import org.scalacheck._ | ||
|
||
class RadiansSpecification extends Properties("Dice") { | ||
|
||
property("all random values are within the range of TAU / 2*PI") = Prop.forAll(Gen.long) { seed => | ||
val dice = Dice.fromSeed(seed) | ||
val value = Radians.random(dice) | ||
|
||
value.toDouble >= 0.0 && value.toDouble <= Radians.TAU.toDouble | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
indigo/indigo/src/test/scala/indigo/shared/datatypes/SizeSpecification.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package indigo.shared.datatypes | ||
|
||
import indigo.shared.dice.Dice | ||
import org.scalacheck._ | ||
|
||
class SizeSpecification extends Properties("Dice") { | ||
|
||
property("all random values are within the max range and >= 0") = Prop.forAll(Gen.choose(0, 500)) { max => | ||
val dice = Dice.fromSeed(0) | ||
val value = Size.random(dice, max) | ||
|
||
value.width >= 0 && value.height >= 0 && value.width <= max && value.height <= max | ||
} | ||
|
||
property("all random values are within the max range (Size) and >= 0") = Prop.forAll(Gen.choose(0, 500)) { max => | ||
val dice = Dice.fromSeed(0) | ||
val value = Size.random(dice, Size(max)) | ||
|
||
value.width >= 0 && value.height >= 0 && value.width <= Size(max).width && value.height <= Size(max).height | ||
} | ||
|
||
property("all random values are within the min / max range") = Prop.forAll(Gen.choose(-500, 0), Gen.choose(0, 500)) { | ||
(min, max) => | ||
val dice = Dice.fromSeed(0) | ||
val value = Size.random(dice, min, max) | ||
|
||
value.width >= min && value.height >= min && value.width <= max && value.height <= max | ||
} | ||
|
||
property("all random values are within the min / max range (Size)") = Prop.forAll(Gen.choose(-500, 0), Gen.choose(0, 500)) { | ||
(min, max) => | ||
val dice = Dice.fromSeed(0) | ||
val value = Size.random(dice, Size(min), Size(max)) | ||
|
||
value.width >= Size(min).width && value.height >= Size(min).height && value.width <= Size(max).width && value.height <= Size(max).height | ||
} | ||
|
||
} |