mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-23 00:18:59 +02:00
b2/test/: more substitution tests
Total number of tests is now 109.
This commit is contained in:
parent
cc895fe7fc
commit
12b21f032c
103
b2/test/sublast
Executable file
103
b2/test/sublast
Executable file
@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
. ./Common
|
||||
|
||||
###############################################################################
|
||||
|
||||
tst "substitutions: expand \$ from regular var" -q X=foo <<EOF
|
||||
!-s
|
||||
X=?*? { Y=\$\$ }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=foo
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: expand \$ from FN" -q F1=bar <<EOF
|
||||
!-s
|
||||
FN=?*? { Y=\$\$ }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=bar
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst_fail "substitutions: expand \$ without match" <<EOF
|
||||
!-s
|
||||
X=\$\$
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
s:2: \$\$ without match
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: assign to \$ from regular var" -q X=bar <<EOF
|
||||
!-s
|
||||
X=?*? { \$=foo }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
X=foo
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: assign to \$ from FN" -q F1=foo <<EOF
|
||||
!-s
|
||||
FN=?*? { \$=bar }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
F1=bar
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst_fail "substitutions: assign to \$ without match" <<EOF
|
||||
!-s
|
||||
\$=bar
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
s:2: \$ without match
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: match \$ from regular var" -q X=bar <<EOF
|
||||
!-s
|
||||
X=?*? { \$=b(*) { Y=\$1 } }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=ar
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: match \$ from FN" -q F1=foo <<EOF
|
||||
!-s
|
||||
FN=?*? { \$=(*)o { Y=\$1 } }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=fo
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst_fail "substitutions: match \$ without match" <<EOF
|
||||
!-s
|
||||
\$=* { X=X }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
s:2: \$ without match
|
||||
EOF
|
||||
|
||||
###############################################################################
|
205
b2/test/subunit
Executable file
205
b2/test/subunit
Executable file
@ -0,0 +1,205 @@
|
||||
#!/bin/bash
|
||||
. ./Common
|
||||
|
||||
###############################################################################
|
||||
|
||||
tst "substitutions: expand \$1 from unit pattern (100R)" -ds -q X=100R <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
X=RE {
|
||||
Y=\$1
|
||||
}
|
||||
Y=100R
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: expand \$\$ from unit pattern (100R)" -q X=100R <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$\$ }
|
||||
EOF
|
||||
|
||||
# this seems to do the right thing but is still wrong
|
||||
expect <<EOF
|
||||
Y=100R
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: expand \$1 from unit pattern (1k2)" -q X=1k2 <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=1.2kR
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: expand \$\$ from unit pattern (1k2)" -q X=1k2 <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$\$ }
|
||||
EOF
|
||||
|
||||
# this isn't what we normally want
|
||||
expect <<EOF
|
||||
Y=1k2
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: expand src var from unit pattern (1R2)" -q X=1R2 <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$X }
|
||||
EOF
|
||||
|
||||
# this isn't what we normally want
|
||||
expect <<EOF
|
||||
Y=1R2
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 100 with unit pattern" -q X=100 <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=100R
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 56k with unit pattern" -q X=56k <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=56kR
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 4u7 with unit pattern" -q X=4u7 <<EOF
|
||||
!-s
|
||||
X=(#F) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=4.7uF
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 3V3 with unit pattern" -q X=3V3 <<EOF
|
||||
!-s
|
||||
X=(#V) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=3.3V
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 0.8A with unit pattern" -q X=0.8A <<EOF
|
||||
!-s
|
||||
X=(#A) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=0.8A
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert 100mV with unit pattern" -q X=100mV <<EOF
|
||||
!-s
|
||||
X=(#V) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=100mV
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: convert -1.5A with unit pattern" -q X=-1.5A <<EOF
|
||||
!-s
|
||||
X=(#A) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=-1.5A
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: try to match 1k8R with unit pattern" -q X=1k8R <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=X }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: try to match 2R2k with unit pattern" -q X=2R2k <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=X }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: try to match 1.2.3 with unit pattern" -q X=1.2.3 <<EOF
|
||||
!-s
|
||||
X=(#R) { Y=X }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: unit pattern (#%)" -q X=10% <<EOF
|
||||
!-s
|
||||
X=(#%) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=10%
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst "substitutions: unit pattern (##)" -q X=1M2 <<EOF
|
||||
!-s
|
||||
X=(##) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
Y=1.2M
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
tst_fail "substitutions: unit pattern (#ppm)" -q X=20ppm <<EOF
|
||||
!-s
|
||||
X=(#ppm) { Y=\$1 }
|
||||
EOF
|
||||
|
||||
expect <<EOF
|
||||
s:2: invalid (#unit) syntax
|
||||
EOF
|
||||
|
||||
###############################################################################
|
Loading…
Reference in New Issue
Block a user