Commit 53c968db authored by Ben Gamari's avatar Ben Gamari 🐢
Browse files

Add hacked test to ensure that literal rules fire

parent b35e38ca
{-# 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 = [ "\0abstime", "\0aclitem", "\xfefe bit", "\0bool", "\0box", "\0bpchar", "\0bytea" ]
-- 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" ]
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
#!/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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment