1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
# encoding: UTF-8
# KLayout Layout Viewer
# Copyright (C) 2006-2025 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
if !$:.member?(File::dirname($0))
$:.push(File::dirname($0))
end
load("test_prologue.rb")
def nt_tech_to_s(t)
t.each.collect do |s|
([ "Stack [" + s.name + "]:" ] +
s.each_connection.collect { |c| " conn: " + c.layer_a + "," + c.via_layer + "," + c.layer_b } +
s.each_symbol.collect { |c| " symbol: " + c.symbol + "=" + c.expression }).join("\n")
end.join("\n") + "\n"
end
class LAYTechnologies_TestClass < TestBase
def test_1
RBA::Technology::technologies_from_xml(<<END)
<technologies>
<technology>
<name/>
</technology>
<technology>
<name>MINE</name>
</technology>
</technologies>
END
assert_equal(RBA::Technology::technology_names.inspect, '["", "MINE"]')
s = RBA::Technology::technologies_to_xml
RBA::Technology::technologies_from_xml("<technologies/>")
assert_equal(RBA::Technology::technology_names.inspect, '[""]')
RBA::Technology::technologies_from_xml(s)
assert_equal(RBA::Technology::technology_names.inspect, '["", "MINE"]')
tech = RBA::Technology::technology_by_name("MINE")
assert_equal(tech.name, "MINE")
tech.name = "MINE2"
assert_equal(tech.name, "MINE2")
assert_equal(RBA::Technology::technology_names.inspect, '["", "MINE2"]')
assert_equal(RBA::Technology::has_technology?("MINE"), false)
assert_equal(RBA::Technology::has_technology?("MINE2"), true)
tech = RBA::Technology::technology_by_name("MINE")
assert_equal(tech != nil, true)
assert_equal(tech.name, "")
tech2 = RBA::Technology::technology_by_name("MINE2")
assert_equal(tech != nil, true)
RBA::Technology::remove_technology("X")
assert_equal(RBA::Technology::technology_names.inspect, '["", "MINE2"]')
RBA::Technology::remove_technology("MINE2")
assert_equal(RBA::Technology::technology_names.inspect, '[""]')
# registration
tech = RBA::Technology::new
tech.name = "NEW"
tech.dbu = 0.5
tech_new = RBA::Technology::register_technology(tech)
tech._destroy
assert_equal(RBA::Technology::technology_names.inspect, '["", "NEW"]')
assert_equal(tech_new.dbu, 0.5)
assert_equal(tech_new.name, "NEW")
end
def test_2
tech = RBA::Technology::technology_from_xml(<<END)
<technology>
<name>X</name>
</technology>
END
assert_equal(tech.name, "X")
tech.name = "Y"
assert_equal(tech.name, "Y")
tech.description = "A big Y"
assert_equal(tech.description, "A big Y")
tech.dbu = 5.0
assert_equal(tech.dbu, 5.0)
tech.default_grids = []
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "")
assert_equal("%.12g" % tech.default_grid, "0")
tech.default_grids = [0.001, 0.01, 0.2]
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "0.001,0.01,0.2")
tech.default_grids = [1]
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "1")
assert_equal("%.12g" % tech.default_grid, "0")
# setting the default grid
tech.set_default_grids([0.01,0.02,0.05], 0.02)
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "0.01,0.02,0.05")
assert_equal("%.12g" % tech.default_grid, "0.02")
# default grid must be a member of the default grid list
tech.set_default_grids([0.01,0.02,0.05], 0.2)
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "0.01,0.02,0.05")
assert_equal("%.12g" % tech.default_grid, "0")
# "default_grids=" resets the default grid
tech.set_default_grids([0.01,0.02,0.05], 0.02)
assert_equal("%.12g" % tech.default_grid, "0.02")
tech.default_grids = [1]
assert_equal(tech.default_grids.collect { |g| "%.12g" % g }.join(","), "1")
assert_equal("%.12g" % tech.default_grid, "0")
tech.default_base_path = "/default/path"
assert_equal(tech.default_base_path, "/default/path")
assert_equal(tech.base_path, "/default/path")
assert_equal(tech.correct_path("/default/path/myfile.xml"), "myfile.xml")
assert_equal(tech.eff_path("myfile.xml").gsub("\\", "/"), "/default/path/myfile.xml")
tech.explicit_base_path = "/basic/path"
assert_equal(tech.explicit_base_path, "/basic/path")
assert_equal(tech.base_path, "/basic/path")
assert_equal(tech.correct_path("/basic/path/myfile.xml"), "myfile.xml")
assert_equal(tech.eff_path("myfile.xml").gsub("\\", "/"), "/basic/path/myfile.xml")
tech.layer_properties_file = "x.lyp"
assert_equal(tech.layer_properties_file, "x.lyp")
assert_equal(tech.eff_layer_properties_file.gsub("\\", "/"), "/basic/path/x.lyp")
tech.add_other_layers = true
assert_equal(tech.add_other_layers?, true)
tech.add_other_layers = false
assert_equal(tech.add_other_layers?, false)
opt = tech.load_layout_options
opt.dxf_dbu = 2.5
tech.load_layout_options = opt
assert_equal(tech.load_layout_options.dxf_dbu, 2.5)
opt = tech.save_layout_options
opt.dbu = 0.125
tech.save_layout_options = opt
assert_equal(tech.save_layout_options.dbu, 0.125)
assert_equal(tech.component_names.size > 0, true)
assert_equal(tech.component_names.find("connectivity") != nil, true)
assert_equal(tech.component("connectivity").class.to_s, "RBA::NetTracerTechnologyComponent")
end
# issue 1245
def test_3
# empty connectivity
tech = RBA::Technology::technology_from_xml(<<END)
<technology>
<name>X</name>
<connectivity/>
</technology>
END
nt_tech = tech.component("connectivity")
assert_equal(nt_tech_to_s(nt_tech), "\n")
# 0.27 to 0.28 migration
tech = RBA::Technology::technology_from_xml(<<END)
<technology>
<name>X</name>
<connectivity>
<connection>11,2,3</connection>
<connection>14,5,6</connection>
<symbols>AA=17</symbols>
<symbols>BB=42</symbols>
</connectivity>
</technology>
END
nt_tech = tech.component("connectivity")
assert_equal(nt_tech_to_s(nt_tech), <<END)
Stack []:
conn: 11,2,3
conn: 14,5,6
symbol: AA=17
symbol: BB=42
END
# 0.28 way
tech = RBA::Technology::technology_from_xml(<<END)
<technology>
<name>X</name>
<connectivity>
<stack>
<name>ST1</name>
<connection>1,2,3</connection>
<connection>4,5,6</connection>
<symbols>A=17</symbols>
<symbols>B=42</symbols>
</stack>
<stack>
<name>ST2</name>
<connection>1,2,3</connection>
<connection>4,5,7</connection>
<symbols>A=1</symbols>
</stack>
<!-- ignored: -->
<connection>1,2,3</connection>
<connection>4,5,6</connection>
<symbols>AA=17</symbols>
<symbols>BB=42</symbols>
</connectivity>
</technology>
END
nt_tech = tech.component("connectivity")
assert_equal(nt_tech_to_s(nt_tech), <<END)
Stack [ST1]:
conn: 1,2,3
conn: 4,5,6
symbol: A=17
symbol: B=42
Stack [ST2]:
conn: 1,2,3
conn: 4,5,7
symbol: A=1
END
end
end
load("test_epilogue.rb")
|