mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-25 19:19:20 +02:00
12b21f032c
Total number of tests is now 109.
206 lines
3.8 KiB
Bash
Executable File
206 lines
3.8 KiB
Bash
Executable File
#!/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
|
|
|
|
###############################################################################
|