Moved mapPair into Utils, and renamed it to transformPair (to be consistent with the pre-existing transformX functions)

This commit is contained in:
Neil Brown 2007-11-02 16:44:02 +00:00
parent b291901f5c
commit 4bb2b2a407
3 changed files with 6 additions and 4 deletions

View File

@ -96,15 +96,12 @@ testGraph testName nodes edges proc
deNode :: FNode a -> (Meta, a)
deNode (Node x) = x
mapPair :: (x -> a) -> (y -> b) -> (x,y) -> (a,b)
mapPair f g (x,y) = (f x, g y)
testOps :: GraphLabelFuncs (State (Map.Map Meta Int)) Int
testOps = GLF nextId nextId nextId nextId (nextId' 100) (nextId' 100)
checkGraphEquality :: (Graph g, Show b, Ord b) => ([(Int, Meta)], [(Int, Int, b)]) -> g (FNode Int) b -> Assertion
checkGraphEquality (nodes, edges) g
= do let (remainingNodes, nodeLookup, ass) = foldl checkNodeEquality (Map.fromList (map revPair nodes),Map.empty, return ()) (map (mapPair id deNode) $ labNodes g)
= do let (remainingNodes, nodeLookup, ass) = foldl checkNodeEquality (Map.fromList (map revPair nodes),Map.empty, return ()) (map (transformPair id deNode) $ labNodes g)
ass
assertBool (testName ++ " Test graph had nodes not found in the real graph: " ++ show remainingNodes ++ ", real graph: " ++ showGraph g) (Map.null remainingNodes)
edges' <- mapM (transformEdge nodeLookup) edges

View File

@ -102,3 +102,7 @@ combineCompare [] = EQ
combineCompare (LT:_) = LT
combineCompare (GT:_) = GT
combineCompare (EQ:os) = combineCompare os
-- | Maps two functions over members of a pair
transformPair :: (x -> a) -> (y -> b) -> (x,y) -> (a,b)
transformPair f g (x,y) = (f x, g y)

View File

@ -28,6 +28,7 @@ import FlowGraph
import Metadata
import RainUsageCheck
import TestUtil
import Utils
--Shorthands for some variables to simplify the list of tests in this file