Skip to content
Snippets Groups Projects
Commit 4cc6d2c3 authored by Orestis Melkonian's avatar Orestis Melkonian
Browse files

Tests: silence stderr

parent 3f105397
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,8 @@ main = defaultMain
[ constructTestSuite testName testSuite
| (testName, testSuite) <- [
("LIR_PARSER", parserTests)
, ("EXAMPLES", examples)
, ("MODEL_PARSER", modelParserTests)
, ("EXAMPLES", examples)
, ("EQUIV_REAL", genEquivTests "examples/test_equiv/Reals.java")
, ("EQUIV_ARRAY", genEquivTests "examples/test_equiv/Arrays.java")
]
......
module TEquivalenceClasses where
import Control.Monad
import Data.List (elemIndex)
import Data.List.Split (splitOn)
import Data.List (elemIndex)
import Data.List.Split (splitOn)
import Data.Maybe
import System.IO.Silently (silence)
import System.IO.Unsafe (unsafePerformIO)
import System.IO (stderr, stdout)
import System.IO.Silently (hSilence)
import System.IO.Unsafe (unsafePerformIO)
import Test.HUnit
import API
import Javawlp.Engine.HelperFunctions (parseMethodIds)
import Model
import API
testEquiv :: Response -> String -> String -> String -> Assertion
testEquiv b src s s' =
(case unsafePerformIO (silence $ compareSpec Debug File (src, s) (src, s')) of
(case unsafePerformIO (hSilence [stdout, stderr] $ compareSpec Debug File (src, s) (src, s')) of
NotEquivalent x -> NotEquivalent emptyModel
x -> x
) @?= b
......@@ -22,7 +23,7 @@ testEquiv b src s s' =
(.!=) = testEquiv $ NotEquivalent emptyModel
genEquivTests edslSrc =
let methodIds = unsafePerformIO (silence $ parseMethodIds edslSrc)
let methodIds = unsafePerformIO (hSilence [stdout, stderr] $ parseMethodIds edslSrc)
getClass = last . splitOn "_"
tailFrom :: Eq a => [a] -> a -> [a]
tailFrom xs x = case elemIndex x xs of Just i -> snd $ splitAt i xs
......
module TExamples where
import System.IO.Unsafe (unsafePerformIO)
import System.IO.Silently (silence)
import System.IO (stderr, stdout)
import System.IO.Silently (hSilence)
import System.IO.Unsafe (unsafePerformIO)
import Test.HUnit
import Model
import API
import Model
src = "examples/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java"
testEquiv :: Response -> String -> String -> Assertion
testEquiv b s s' =
(case unsafePerformIO (silence $ compareSpec Debug File (src, s) (src, s')) of
(case unsafePerformIO (hSilence [stdout, stderr] $ compareSpec Debug File (src, s) (src, s')) of
NotEquivalent _ -> NotEquivalent emptyModel
x -> x
x -> x
) @?= b
(.==) = testEquiv Equivalent
(.!=) = testEquiv $ NotEquivalent emptyModel
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment