Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
text
Commits
53c968db
Commit
53c968db
authored
Jul 30, 2015
by
Ben Gamari
🐢
Browse files
Add hacked test to ensure that literal rules fire
parent
b35e38ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/LiteralRuleTest.hs
0 → 100644
View file @
53c968db
{-# LANGUAGE OverloadedStrings #-}
module
LiteralRuleTest
where
import
Data.Text
(
Text
)
-- This should produce 8 firings of the "TEXT literal" rule
strings
::
[
Text
]
strings
=
[
"abstime"
,
"aclitem"
,
"bit"
,
"bool"
,
"box"
,
"bpchar"
,
"bytea"
,
"char"
]
-- This should produce 7 firings of the "TEXT literal UTF8" rule
utf8Strings
::
[
Text
]
utf8Strings
=
[
"
\0
abstime"
,
"
\0
aclitem"
,
"
\xfefe
bit"
,
"
\0
bool"
,
"
\0
box"
,
"
\0
bpchar"
,
"
\0
bytea"
]
-- This should produce 4 firings of the "TEXT empty literal" rule
empties
::
[
Text
]
empties
=
[
""
,
""
,
""
,
""
]
-- This should produce 5 firings of the "TEXT empty literal" rule
--singletons :: [Text]
--singletons = [ "a", "b", "c", "d", "e" ]
tests/Makefile
View file @
53c968db
count
=
1000
all
:
coverage literal-rule-test
literal-rule-test
:
./literal-rule-test.sh
coverage
:
build coverage/hpc_index.html
build
:
text-test-data
...
...
@@ -32,4 +37,4 @@ coverage/hpc_index.html: coverage/coverage.tix
clean
:
rm
-rf
dist coverage .hpc
.PHONY
:
build coverage
.PHONY
:
build coverage
all literal-rule-test
tests/literal-rule-test.sh
0 → 100755
View file @
53c968db
#!/bin/bash -e
failed
=
0
function
check_firings
()
{
rule
=
$1
expected
=
$2
build
=
"ghc -O -ddump-rule-firings LiteralRuleTest.hs"
build
=
"
$build
-i.. -I../include -DMIN_VERSION_bytestring(a,b,c)=1"
touch
LiteralRuleTest.hs
echo
-n
"Want to see
$expected
firings of rule
$rule
... "
>
&2
firings
=
$(
$build
2>&1 |
grep
"Rule fired:
$rule
\$
"
|
wc
-l
)
rm
-f
LiteralRuleTest.
{
o.hi
}
if
[
$firings
!=
$expected
]
;
then
echo
"failed, saw
$firings
"
>
&2
failed
=
1
else
echo
"pass"
>
&2
fi
}
check_firings
"TEXT literal"
8
check_firings
"TEXT literal UTF8"
7
check_firings
"TEXT empty literal"
4
# This is broken at the moment. "TEXT literal" rule fires instead.
#check_firings "TEXT singleton literal" 5
exit
$failed
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment