Skip to content

Commit

Permalink
simple framework for update-policy-like thing in grammarware
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed May 30, 2012
1 parent a889685 commit 1d134d3
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 0 deletions.
23 changes: 23 additions & 0 deletions topics/transformation/update/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
all:
make build
make test

build:
cp ../../convergence/xbgf/fl/snapshot/rascal.bgf tests/bad-f/g1.bgf
cp ../../convergence/xbgf/fl/snapshot/rascal.bgf tests/bad-d/g1.bgf
cp ../../convergence/xbgf/fl/snapshot/rascal.bgf tests/independent/g1.bgf
cp ../../convergence/xbgf/fl/snapshot/rascal.bgf tests/input/g1.bgf
cp ../../convergence/xbgf/fl/snapshot/rascal.bgf tests/incompatible/g1.bgf

test:
./testperform bad-f || echo "Ok"
./testperform bad-d || echo "Ok"
./testperform independent || echo "Ok"
./testperform input || echo "Ok"
./testperform incompatible || echo "Ok"

quiet:
make test 2> /dev/null | grep OUTCOME

clean:
rm -f tests/*/g?.bgf tests/*/*.cbgf tests/*/d-1*.xbgf
38 changes: 38 additions & 0 deletions topics/transformation/update/testperform
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

echo [Test Update] $1
../../../shared/tools/checkxml xbgf tests/$1/f.xbgf || exit -1
../../../shared/tools/checkxml xbgf tests/$1/d.xbgf || exit -1
../../../shared/tools/checkxml bgf tests/$1/g1.bgf || exit -1
# let's try f of G1
../../../shared/tools/xbgf tests/$1/f.xbgf tests/$1/g1.bgf tests/$1/g2.bgf
if [ $? -ne 0 ]
then
echo "OUTCOME for $1: Impossible output — bad f."
exit -1
fi
# let's try ∆ of G1
../../../shared/tools/xbgf tests/$1/d.xbgf tests/$1/g1.bgf tests/$1/g3.bgf
if [ $? -ne 0 ]
then
echo "OUTCOME for $1: Impossible output — incompatible ∆."
exit -1
fi
# let's try f of ∆ of G1 and ∆ of f of G1
../../../shared/tools/xbgf tests/$1/f.xbgf tests/$1/g3.bgf tests/$1/g4.bgf && ../../../shared/tools/xbgf tests/$1/d.xbgf tests/$1/g2.bgf tests/$1/g5.bgf && gdt tests/$1/g4.bgf tests/$1/g5.bgf
if [ $? -eq 0 ]
then
echo "OUTCOME for $1: f and ∆ are independent; any composition is valid."
exit -1
fi
# let's try f of ∆ of G1 and ∆ of f of G1
../../../shared/tools/xbgf2cbgf tests/$1/d.xbgf tests/$1/d.cbgf tests/$1/g1.bgf
../../../shared/tools/cbgf2xbgf tests/$1/d.cbgf /dev/null tests/$1/d-1.xbgf
../../../shared/tools/appendxbgf tests/$1/d-1-f.xbgf tests/$1/d-1.xbgf tests/$1/f.xbgf
../../../shared/tools/xbgf tests/$1/d-1-f.xbgf tests/$1/g3.bgf tests/$1/g6.bgf && gdt tests/$1/g2.bgf tests/$1/g6.bgf
if [ $? -eq 0 ]
then
echo "OUTCOME for $1: ∆ messes with input of f; a composition with reversed ∆ is valid."
exit -1
fi
echo "OUTCOME for $1: f and ∆ are incompatible."
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/bad-d/d.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Prg</from>
<to>Program</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/bad-d/f.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/bad-f/d.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/bad-f/f.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Prg</from>
<to>Program</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/incompatible/d.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Function</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/incompatible/f.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/independent/d.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Name</from>
<to>Identifier</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/independent/f.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/input/d.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Exp</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>
9 changes: 9 additions & 0 deletions topics/transformation/update/tests/input/f.xbgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:rename>
<nonterminal>
<from>Expr</from>
<to>Expression</to>
</nonterminal>
</xbgf:rename>
</xbgf:sequence>

0 comments on commit 1d134d3

Please sign in to comment.