Added some testcases related to checking the use of abbreviations

This commit is contained in:
Neil Brown 2009-02-08 23:25:30 +00:00
parent e165030751
commit 3604ab6412
3 changed files with 65 additions and 6 deletions

View File

@ -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

View File

@ -16,15 +16,18 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
-}
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"
]

View File

@ -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
%