Permalink
Browse files

Renamed QuickCheck tests to "prop_<camel case thing>".

All the underscore usage was clashing with camel case elsewhere. So I've
switched to using "prop_<camel case>". I'm aware of the apparent illogic
in switching to a mixture of underscore and camel case, but I also want
property checks to stand out easily and "prop_" does that.
  • Loading branch information...
1 parent aa26672 commit f018bf9e72f026080979682ceec59b0c4b66202d @malcolmt committed Oct 31, 2011
Showing with 22 additions and 23 deletions.
  1. +11 −11 src/ChessTools/Test/Board.hs
  2. +11 −12 src/ChessTools/Test/Suite.hs
@@ -66,30 +66,30 @@ boardAndIndexGen = do
-- other. That is:
-- index -> square -> index should be the identity
-- square -> index -> square should be the identity
-prop_index_to_square_inverse = forAll boardAndIndexGen $ \(b, idx) ->
+prop_indexToSquareInverse = forAll boardAndIndexGen $ \(b, idx) ->
squareToIndex b (indexToSquare b idx) == idx
-prop_square_to_index_inverse = forAll boardAndSquareGen $ \(b, sq) ->
+prop_squareToIndexInverse = forAll boardAndSquareGen $ \(b, sq) ->
indexToSquare b (squareToIndex b sq) == sq
-- As squares move from lower left ("a1" in western chess) to upper right (h8),
-- the index into the lookup table should increase.
-prop_index_increases_with_square = forAll boardAndTwoSquareGen $ \(b, s1, s2) ->
+prop_indexIncreasesWithSquare = forAll boardAndTwoSquareGen $ \(b, s1, s2) ->
let idx1 = squareToIndex b s1
idx2 = squareToIndex b s2
in s1 `compare` s2 == idx1 `compare` idx2
-- The board array size should be computed correctly (this is the
-- representation of the board of pieces, not a lookup array, which is smaller).
-prop_board_array_size bs = boardArraySize bs == expected
+prop_boardArraySize bs = boardArraySize bs == expected
where BoardSize h v vbuf = bs
expected = h * v + v * (h - 1) + 2 * vbuf * (2 * h - 1)
-- The list returned from repIndexList should actually be representative. That
-- is, it should contain as many values as the size of the lookup array and all
-- of the distance values in it should be unique.
-prop_repIndexList_is_representative = forAll smallBoardGen $ \bs ->
+prop_repIndexListRepresents = forAll smallBoardGen $ \bs ->
let cl@(CL xs) = repIndexList bs
(l, u) = lookupBounds cl
in length xs == u - l + 1 &&
@@ -121,10 +121,10 @@ checkLookup lt cmp b = forAll (genTwoSquares b) $ \(sq1, sq2) ->
idx2 = squareToIndex b sq2
in fetch lt idx1 idx2 == cmp sq1 sq2
-prop_check_file_distance_1 = checkLookup fTable1 fileCheckFunc board1
-prop_check_file_distance_2 = checkLookup fTable2 fileCheckFunc board2
-prop_check_rank_distance_1 = checkLookup rTable1 rankCheckFunc board1
-prop_check_rank_distance_2 = checkLookup rTable2 rankCheckFunc board2
-prop_check_square_distance_1 = checkLookup sTable1 squareCheckFunc board1
-prop_check_square_distance_2 = checkLookup sTable2 squareCheckFunc board2
+prop_checkFileDistance1 = checkLookup fTable1 fileCheckFunc board1
+prop_checkFileDistance2 = checkLookup fTable2 fileCheckFunc board2
+prop_checkRankDistance1 = checkLookup rTable1 rankCheckFunc board1
+prop_checkRankDistance2 = checkLookup rTable2 rankCheckFunc board2
+prop_checkSquareDistance1 = checkLookup sTable1 squareCheckFunc board1
+prop_checkSquareDistance2 = checkLookup sTable2 squareCheckFunc board2
@@ -17,20 +17,19 @@ main = defaultMain tests
tests = [
testGroup "Board arrays" [
- testProperty "index to square" prop_index_to_square_inverse
- , testProperty "square to index" prop_square_to_index_inverse
- , testProperty "indices increase" prop_index_increases_with_square
- , testProperty "array size" prop_board_array_size
+ testProperty "index to square" prop_indexToSquareInverse
+ , testProperty "square to index" prop_squareToIndexInverse
+ , testProperty "indices increase" prop_indexIncreasesWithSquare
+ , testProperty "array size" prop_boardArraySize
]
, testGroup "Lookup arrays" [
- testProperty "repIndexList represents"
- prop_repIndexList_is_representative
- , testProperty "file lookup 1" prop_check_file_distance_1
- , testProperty "file lookup 2" prop_check_file_distance_2
- , testProperty "rank lookup 1" prop_check_rank_distance_1
- , testProperty "rank lookup 2" prop_check_rank_distance_2
- , testProperty "square lookup 1" prop_check_square_distance_1
- , testProperty "square lookup 2" prop_check_square_distance_2
+ testProperty "repIndexList represents" prop_repIndexListRepresents
+ , testProperty "file lookup 1" prop_checkFileDistance1
+ , testProperty "file lookup 2" prop_checkFileDistance2
+ , testProperty "rank lookup 1" prop_checkRankDistance1
+ , testProperty "rank lookup 2" prop_checkRankDistance2
+ , testProperty "square lookup 1" prop_checkSquareDistance1
+ , testProperty "square lookup 2" prop_checkSquareDistance2
]
, testGroup "Western notation" [
testProperty "good algebraic squares" prop_goodAlgebraicSquares

0 comments on commit f018bf9

Please sign in to comment.