Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 47 lines (40 sloc) 767 Bytes
#!/bin/bash
set -e
: ${RUBY:=ruby}
enc() {
$RUBY -r ./okjson -e 'puts(OkJson.encode(eval($stdin.read)))'
}
cycle() {
$RUBY -r ./okjson -e 'puts(OkJson.encode(OkJson.decode($stdin.read)))'
}
fs=$*
if test -z "$fs"
then fs=`echo t/*.{json,rb}`
fi
for f in $fs
do
case $f in
t/valid*.json)
echo $f
cycle <$f >/dev/null
diff $f.exp <(cycle <$f 2>/dev/null)
;;
t/invalid*.json)
echo $f
if cycle <$f 2>/dev/null
then echo; exit 1
fi
;;
t/encode*.rb)
echo $f
enc <$f >/dev/null
diff $f.exp <(enc <$f 2>/dev/null)
;;
t/err*.rb)
echo $f
if enc <$f 2>/dev/null
then echo; exit 1
fi
;;
esac
done