1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-05 12:32:28 +02:00
eda-tools/b2/test/hierrul
Werner Almesberger 9cafe23fb8 b2/: simplified and corrected logic behind relop_redundant
We now generate the operator map algorithmically, which is a bit less
classy than solving the logical equations, but easier to get right.

Also renamed the somewhat vague "redundant" to "unreachable".
2012-06-01 14:52:12 -03:00

308 lines
5.1 KiB
Bash
Executable File

#!/bin/bash
. ./Common
#
# Note: the hierarchy dump differs in some details from the input format.
# Its main purpose is to aid with debugging, not to produce a syntactically
# valid representation of the currently loaded hierarchy.
#
###############################################################################
tst "hierarchy: name rule" <<EOF
Animal=* {
Cat: { X=* };
Dog: { Y=* };
};
EOF
expect <<EOF
Animal=* {
Cat: { X=* }
Dog: { Y=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: name set rule" <<EOF
<predation> = mouse<cat<dog;
p = <predation> {
mouse: { X=* };
cat: { Y=* };
dog: { Z=* };
};
EOF
expect <<EOF
p=<predation> {
mouse: { X=* }
cat: { Y=* }
dog: { Z=* }
}
EOF
#------------------------------------------------------------------------------
tst_fail "hierarchy: name set rule (invalid value)" <<EOF
<predation> = mouse<cat<dog;
p = <predation> {
mouse: { X=* };
cat: { Y=* };
boat: { Z=* };
};
EOF
expect <<EOF
h:6: invalid value in selection
EOF
#------------------------------------------------------------------------------
tst "hierarchy: name set rule (duplicate entry)" <<EOF
<predation> = mouse<cat<dog;
p = <predation> {
mouse: { X=* };
cat: { Y=* };
cat: { Z=* };
};
EOF
expect <<EOF
h:6: warning: unreachable condition
p=<predation> {
mouse: { X=* }
cat: { Y=* }
cat: { Z=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: absolute value rule (with unit)" <<EOF
<predation> = mouse<cat<dog;
N=#R {
10R: { X=* };
10k: { Y=* };
1.2R: { Z=* };
};
EOF
expect <<EOF
N=#R {
10R: { X=* }
10000R: { Y=* }
1.2R: { Z=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: absolute value rule (without unit)" <<EOF
<predation> = mouse<cat<dog;
N=## {
2: { X=* };
5k: { Y=* };
3.1: { Z=* };
};
EOF
expect <<EOF
N=## {
2: { X=* }
5000: { Y=* }
3.1: { Z=* }
}
EOF
#------------------------------------------------------------------------------
tst_fail "hierarchy: absolute value rule (different unit)" <<EOF
<predation> = mouse<cat<dog;
N=#R {
1.0A: { X=* };
};
EOF
expect <<EOF
h:4: invalid value in selection
EOF
#------------------------------------------------------------------------------
tst_fail "hierarchy: absolute value rule (letter-as-decimal syntax)" <<EOF
<predation> = mouse<cat<dog;
N=#R {
1k2: { X=* };
};
EOF
expect <<EOF
h:4: invalid value in selection
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (percent)" <<EOF
{ V=#R }
TOL=%V {
1%: { X=* };
1.2%: { Y=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-1/+1%: { X=* }
-1.2/+1.2%: { Y=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (absolute, with unit)" <<EOF
{ V=#R }
TOL=%V {
1R: { X=* };
1kR: { Y=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-1/+1R: { X=* }
-1000/+1000R: { Y=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (absolute, without unit)" <<EOF
{ V=## }
TOL=%V {
1: { X=* };
1k: { Y=* };
};
EOF
expect <<EOF
{ V=## }
TOL=%# {
-1/+1: { X=* }
-1000/+1000: { Y=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (plus/minus percent)" <<EOF
{ V=#R }
TOL=%V {
+10/-20%: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-20/+10%: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (minus/plus percent)" <<EOF
{ V=#R }
TOL=%V {
-10/+20%: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-10/+20%: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (implicit minus/plus percent)" <<EOF
{ V=#R }
TOL=%V {
10/20%: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-10/+20%: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (plus/minus absolute)" <<EOF
{ V=#R }
TOL=%V {
+10/-20R: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-20/+10R: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (minus/plus absolute)" <<EOF
{ V=#R }
TOL=%V {
-5/+10R: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-5/+10R: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst "hierarchy: relative value rule (implicit minus/plus absolute)" <<EOF
{ V=#R }
TOL=%V {
0/10R: { X=* };
};
EOF
expect <<EOF
{ V=#R }
TOL=%R {
-0/+10R: { X=* }
}
EOF
#------------------------------------------------------------------------------
tst_fail "hierarchy: relative value rule (unknown field)" <<EOF
{ V=#R }
TOL=%X {
10%: { Y=* };
};
EOF
expect <<EOF
h:2: unknown field "X"
EOF
###############################################################################