diff --git a/TestMain.hs b/TestMain.hs index 0cbfd51..92ba6a4 100644 --- a/TestMain.hs +++ b/TestMain.hs @@ -66,7 +66,7 @@ import Test.HUnit import qualified AnalyseAsmTest (tests) import qualified ArrayUsageCheckTest (vioqcTests) import qualified BackendPassesTest (qcTests) -import qualified CheckTest (tests) +import qualified CheckTest (viotests) import qualified CommonTest (tests) import qualified FlowGraphTest (qcTests) import qualified GenerateCTest (tests) @@ -188,7 +188,7 @@ main = do (opts, nonOpts, errs) <- getArgs >>* getOpt RequireOrder options noqc AnalyseAsmTest.tests ,ArrayUsageCheckTest.vioqcTests v ,return BackendPassesTest.qcTests - ,noqc CheckTest.tests + ,noqcButIO $ CheckTest.viotests v ,noqc CommonTest.tests ,return FlowGraphTest.qcTests ,noqc GenerateCTest.tests diff --git a/checks/CheckTest.hs b/checks/CheckTest.hs index 0520753..3f0ae11 100644 --- a/checks/CheckTest.hs +++ b/checks/CheckTest.hs @@ -16,15 +16,18 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -} -module CheckTest (tests) where +module CheckTest (viotests) where +import Control.Monad import Test.HUnit import qualified AST as A import Check import CheckFramework +import CompState import Metadata import OccamEDSL +import TestHarness import TestUtils testUnusedVar :: Test @@ -98,10 +101,11 @@ testUnusedVar = TestList testWarn n name x = testOccamPassWarn ("checkUnusedVar " ++ name) ((== n) . length) x (runChecksPass checkUnusedVar) -tests :: Test -tests = TestLabel "CheckTest" $ TestList +viotests :: Int -> IO Test +viotests v = liftM (TestLabel "CheckTest" . TestList) $ sequence [ - testUnusedVar + return testUnusedVar + ,automaticTest FrontendOccam v "testcases/automatic/abbrev-check-1.occ.test" ] diff --git a/testcases/automatic/abbrev-check-1.occ.test b/testcases/automatic/abbrev-check-1.occ.test new file mode 100644 index 0000000..e0e383f --- /dev/null +++ b/testcases/automatic/abbrev-check-1.occ.test @@ -0,0 +1,55 @@ +-- This file tests abbreviation checking + +PROC m() + INT x: +%% +: + +%PASS Normal abbreviation, used properly + INT z IS x: + z := 3 +%FAIL Normal abbreviation, used improperly + INT z IS x: + x := 3 +%FAIL Val abbreviation, used improperly + VAL INT z IS x: + z := 3 +%FAIL Val abbreviation, used improperly 2 + VAL INT z IS x: + x := 3 +%FAIL Val abbreviation, used properly + VAL INT z IS x: + INT y: + y := z +%PASS Formal normal abbreviation, used properly + PROC p(INT y) + y := 2 + : + p(x) +%PASS Formal val abbreviation, used properly + PROC p(VAL INT y) + INT z: + z := y + : + p(x) +%FAIL Formal val abbreviation, used improperly + PROC p(VAL INT y) + y := 3 + : + p(x) +%FAIL Formal normal abbreviation, overlaps (bad -- KRoC disallows) + PROC p(INT y) + y := x + : + p(x) +%PASS Formal val abbreviation, overlaps (KRoC disallows, I'm unsure) + PROC p(VAL INT y) + x := y + : + p(x) +%PASS Formal normal abbreviation, overlaps, no call + PROC p(INT y) + y := x + : + x := 3 +%