Added some testcases related to checking the use of abbreviations
This commit is contained in:
parent
e165030751
commit
3604ab6412
|
@ -66,7 +66,7 @@ import Test.HUnit
|
||||||
import qualified AnalyseAsmTest (tests)
|
import qualified AnalyseAsmTest (tests)
|
||||||
import qualified ArrayUsageCheckTest (vioqcTests)
|
import qualified ArrayUsageCheckTest (vioqcTests)
|
||||||
import qualified BackendPassesTest (qcTests)
|
import qualified BackendPassesTest (qcTests)
|
||||||
import qualified CheckTest (tests)
|
import qualified CheckTest (viotests)
|
||||||
import qualified CommonTest (tests)
|
import qualified CommonTest (tests)
|
||||||
import qualified FlowGraphTest (qcTests)
|
import qualified FlowGraphTest (qcTests)
|
||||||
import qualified GenerateCTest (tests)
|
import qualified GenerateCTest (tests)
|
||||||
|
@ -188,7 +188,7 @@ main = do (opts, nonOpts, errs) <- getArgs >>* getOpt RequireOrder options
|
||||||
noqc AnalyseAsmTest.tests
|
noqc AnalyseAsmTest.tests
|
||||||
,ArrayUsageCheckTest.vioqcTests v
|
,ArrayUsageCheckTest.vioqcTests v
|
||||||
,return BackendPassesTest.qcTests
|
,return BackendPassesTest.qcTests
|
||||||
,noqc CheckTest.tests
|
,noqcButIO $ CheckTest.viotests v
|
||||||
,noqc CommonTest.tests
|
,noqc CommonTest.tests
|
||||||
,return FlowGraphTest.qcTests
|
,return FlowGraphTest.qcTests
|
||||||
,noqc GenerateCTest.tests
|
,noqc GenerateCTest.tests
|
||||||
|
|
|
@ -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/>.
|
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 Test.HUnit
|
||||||
|
|
||||||
import qualified AST as A
|
import qualified AST as A
|
||||||
import Check
|
import Check
|
||||||
import CheckFramework
|
import CheckFramework
|
||||||
|
import CompState
|
||||||
import Metadata
|
import Metadata
|
||||||
import OccamEDSL
|
import OccamEDSL
|
||||||
|
import TestHarness
|
||||||
import TestUtils
|
import TestUtils
|
||||||
|
|
||||||
testUnusedVar :: Test
|
testUnusedVar :: Test
|
||||||
|
@ -98,10 +101,11 @@ testUnusedVar = TestList
|
||||||
testWarn n name x = testOccamPassWarn ("checkUnusedVar " ++ name) ((== n) . length) x
|
testWarn n name x = testOccamPassWarn ("checkUnusedVar " ++ name) ((== n) . length) x
|
||||||
(runChecksPass checkUnusedVar)
|
(runChecksPass checkUnusedVar)
|
||||||
|
|
||||||
tests :: Test
|
viotests :: Int -> IO Test
|
||||||
tests = TestLabel "CheckTest" $ TestList
|
viotests v = liftM (TestLabel "CheckTest" . TestList) $ sequence
|
||||||
[
|
[
|
||||||
testUnusedVar
|
return testUnusedVar
|
||||||
|
,automaticTest FrontendOccam v "testcases/automatic/abbrev-check-1.occ.test"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
55
testcases/automatic/abbrev-check-1.occ.test
Normal file
55
testcases/automatic/abbrev-check-1.occ.test
Normal 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
|
||||||
|
%
|
Loading…
Reference in New Issue
Block a user