better testing with compilation
This commit is contained in:
parent
710e049cfa
commit
b0ed22f436
4 changed files with 26 additions and 5 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,3 +1,8 @@
|
|||
# tests & compilation
|
||||
y
|
||||
.tmp
|
||||
|
||||
# haskell
|
||||
dist
|
||||
cabal-dev
|
||||
*.o
|
||||
|
|
14
test.sh
14
test.sh
|
@ -10,6 +10,18 @@ else
|
|||
fi
|
||||
|
||||
tmpfic=tests/tmp
|
||||
|
||||
|
||||
if ((${#listfic}>1)); then
|
||||
# compile
|
||||
[[ ! -d .tmp ]] && mkdir .tmp
|
||||
ghc -O2 -hidir .tmp -odir .tmp y.hs
|
||||
cmd='./y'
|
||||
else
|
||||
cmd=(runghc y.hs)
|
||||
fi
|
||||
|
||||
# test
|
||||
for input in $listfic; do
|
||||
sed 's/\\/\\\\/g' $input > $tmpfic
|
||||
# set 3 as the file descriptor for the file $tmpfic
|
||||
|
@ -21,7 +33,7 @@ for input in $listfic; do
|
|||
(($?!=0)) && {done=1;continue}
|
||||
read <&3 expected
|
||||
(($?!=0)) && {done=1;continue}
|
||||
result="$(runghc y.hs "$program")"
|
||||
result="$($cmd "$program")"
|
||||
printf "%18s (line %3d): " ${input:t} $num
|
||||
if [[ $expected == $result ]]; then
|
||||
print -- "OK"
|
||||
|
|
4
tests/bool
Normal file
4
tests/bool
Normal file
|
@ -0,0 +1,4 @@
|
|||
#t
|
||||
#t
|
||||
#f
|
||||
#f
|
8
y.hs
8
y.hs
|
@ -48,8 +48,8 @@ parseExpr :: Parser LispVal
|
|||
parseExpr = parseString
|
||||
<|> try parseChar -- #\a #\b etc...
|
||||
<|> try parseFloat -- 3.1415
|
||||
<|> parseNumber -- 3, #b011001, #o070, #d930, #xFF3
|
||||
<|> parseAtom -- symbol-323
|
||||
<|> try parseNumber -- 3, #b011001, #o070, #d930, #xFF3
|
||||
<|> try parseAtom -- symbol-323
|
||||
<|> parseQuoted
|
||||
<|> do
|
||||
char '('
|
||||
|
@ -90,8 +90,8 @@ parseAtom = do
|
|||
rest <- many (letter <|> digit <|> symbol)
|
||||
let atom = first:rest
|
||||
return $ case atom of
|
||||
"#vrai" -> Bool True
|
||||
"#faux" -> Bool False
|
||||
"#t" -> Bool True
|
||||
"#f" -> Bool False
|
||||
_ -> Atom atom
|
||||
|
||||
numFromBase n str = foldl' traiteNombre 0 str
|
||||
|
|
Loading…
Reference in a new issue