mirror of https://github.com/KLayout/klayout.git
WIP: unit tests for new features
This commit is contained in:
parent
3a612f9b04
commit
792c06b3a2
|
|
@ -316,7 +316,7 @@ Class<shape_processor_impl<db::EdgePairToPolygonProcessorBase> > decl_EdgePairTo
|
|||
"This class has been introduced in version 0.29.\n"
|
||||
);
|
||||
|
||||
Class<db::EdgePairToEdgeProcessorBase> decl_EdgePairToEdgeProcessorBase ("db", "EdgePairProcessorBase", "@hide");
|
||||
Class<db::EdgePairToEdgeProcessorBase> decl_EdgePairToEdgeProcessorBase ("db", "EdgePairToEdgeProcessorBase", "@hide");
|
||||
|
||||
Class<shape_processor_impl<db::EdgePairToEdgeProcessorBase> > decl_EdgePairToEdgeProcessor (decl_EdgePairToEdgeProcessorBase, "db", "EdgePairToEdgeOperator",
|
||||
shape_processor_impl<db::EdgePairToEdgeProcessorBase>::method_decls (false),
|
||||
|
|
|
|||
|
|
@ -694,6 +694,38 @@ class DBEdgePairs_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# properties
|
||||
def test_prop_expressions
|
||||
|
||||
r = RBA::EdgePairs::new
|
||||
e1 = RBA::Edge::new(0, 0, 1000, 2000)
|
||||
e2 = RBA::Edge::new(-100, 200, 900, 2200)
|
||||
r.insert(RBA::EdgePairWithProperties::new(RBA::EdgePair::new(e1, e2), { "PropA" => 17.0, 1 => 42 }))
|
||||
assert_equal(r.to_s, "(0,0;1000,2000)/(-100,200;900,2200){1=>42,PropA=>17}")
|
||||
|
||||
# replace
|
||||
pr = RBA::EdgePairPropertiesExpressions::new(r, { "X" => "PropA+1", "Y" => "shape.distance", "Z" => "value(1)+1" })
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000)/(-100,200;900,2200){X=>18,Y=>179,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::EdgePairPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.distance", "Z" => "value(1)+1" }, true)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000)/(-100,200;900,2200){1=>42,PropA=>0,X=>18,Y=>179,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::EdgePairPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.distance", "Z" => "value(1)+1" }, true, dbu: 0.001)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000)/(-100,200;900,2200){1=>42,PropA=>0,X=>18,Y=>0.178885438199983,Z=>43}")
|
||||
|
||||
ef = RBA::EdgePairFilterBase::expression_filter("PropX==18")
|
||||
assert_equal(r.filtered(ef).to_s, "")
|
||||
|
||||
ef = RBA::EdgePairFilterBase::expression_filter("PropA==17")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;1000,2000)/(-100,200;900,2200){1=>42,PropA=>17}")
|
||||
|
||||
ef = RBA::EdgePairFilterBase::expression_filter("value(1)>=40")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;1000,2000)/(-100,200;900,2200){1=>42,PropA=>17}")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1104,6 +1104,36 @@ class DBEdges_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# properties
|
||||
def test_prop_expressions
|
||||
|
||||
r = RBA::Edges::new
|
||||
r.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 1000, 2000), { "PropA" => 17.0, 1 => 42 }))
|
||||
assert_equal(r.to_s, "(0,0;1000,2000){1=>42,PropA=>17}")
|
||||
|
||||
# replace
|
||||
pr = RBA::EdgePropertiesExpressions::new(r, { "X" => "PropA+1", "Y" => "shape.length", "Z" => "value(1)+1" })
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000){X=>18,Y=>2236,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::EdgePropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.length", "Z" => "value(1)+1" }, true)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000){1=>42,PropA=>0,X=>18,Y=>2236,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::EdgePropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.length", "Z" => "value(1)+1" }, true, dbu: 0.001)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;1000,2000){1=>42,PropA=>0,X=>18,Y=>2.23606797749979,Z=>43}")
|
||||
|
||||
ef = RBA::EdgeFilterBase::expression_filter("PropX==18")
|
||||
assert_equal(r.filtered(ef).to_s, "")
|
||||
|
||||
ef = RBA::EdgeFilterBase::expression_filter("PropA==17")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;1000,2000){1=>42,PropA=>17}")
|
||||
|
||||
ef = RBA::EdgeFilterBase::expression_filter("value(1)>=40")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;1000,2000){1=>42,PropA=>17}")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
|
|
@ -1699,6 +1699,36 @@ class DBRegion_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# properties
|
||||
def test_prop_expressions
|
||||
|
||||
r = RBA::Region::new
|
||||
r.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 1000, 2000), { "PropA" => 17.0, 1 => 42 }))
|
||||
assert_equal(r.to_s, "(0,0;0,2000;1000,2000;1000,0){1=>42,PropA=>17}")
|
||||
|
||||
# replace
|
||||
pr = RBA::PolygonPropertiesExpressions::new(r, { "X" => "PropA+1", "Y" => "shape.area", "Z" => "value(1)+1" })
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;0,2000;1000,2000;1000,0){X=>18,Y=>2000000,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::PolygonPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.area", "Z" => "value(1)+1" }, true)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;0,2000;1000,2000;1000,0){1=>42,PropA=>0,X=>18,Y=>2000000,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::PolygonPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.area", "Z" => "value(1)+1" }, true, dbu: 0.001)
|
||||
assert_equal(r.processed(pr).to_s, "(0,0;0,2000;1000,2000;1000,0){1=>42,PropA=>0,X=>18,Y=>2,Z=>43}")
|
||||
|
||||
ef = RBA::PolygonFilterBase::expression_filter("PropX==18")
|
||||
assert_equal(r.filtered(ef).to_s, "")
|
||||
|
||||
ef = RBA::PolygonFilterBase::expression_filter("PropA==17")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;0,2000;1000,2000;1000,0){1=>42,PropA=>17}")
|
||||
|
||||
ef = RBA::PolygonFilterBase::expression_filter("value(1)>=40")
|
||||
assert_equal(r.filtered(ef).to_s, "(0,0;0,2000;1000,2000;1000,0){1=>42,PropA=>17}")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
|
|
@ -546,6 +546,36 @@ class DBTexts_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# properties
|
||||
def test_prop_expressions
|
||||
|
||||
r = RBA::Texts::new
|
||||
r.insert(RBA::TextWithProperties::new(RBA::Text::new("T", RBA::Trans::new(100, 200)), { "PropA" => 17.0, 1 => 42 }))
|
||||
assert_equal(r.to_s, "('T',r0 100,200){1=>42,PropA=>17}")
|
||||
|
||||
# replace
|
||||
pr = RBA::TextPropertiesExpressions::new(r, { "X" => "PropA+1", "Y" => "shape.bbox.center.x", "Z" => "value(1)+1" })
|
||||
assert_equal(r.processed(pr).to_s, "('T',r0 100,200){X=>18,Y=>100,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::TextPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.bbox.center.x", "Z" => "value(1)+1" }, true)
|
||||
assert_equal(r.processed(pr).to_s, "('T',r0 100,200){1=>42,PropA=>0,X=>18,Y=>100,Z=>43}")
|
||||
|
||||
# substitutions
|
||||
pr = RBA::TextPropertiesExpressions::new(r, { "PropA" => "0", "X" => "PropA+1", "Y" => "shape.bbox.center.x", "Z" => "value(1)+1" }, true, dbu: 0.001)
|
||||
assert_equal(r.processed(pr).to_s, "('T',r0 100,200){1=>42,PropA=>0,X=>18,Y=>0.1,Z=>43}")
|
||||
|
||||
ef = RBA::TextFilterBase::expression_filter("PropX==18")
|
||||
assert_equal(r.filtered(ef).to_s, "")
|
||||
|
||||
ef = RBA::TextFilterBase::expression_filter("PropA==17")
|
||||
assert_equal(r.filtered(ef).to_s, "('T',r0 100,200){1=>42,PropA=>17}")
|
||||
|
||||
ef = RBA::TextFilterBase::expression_filter("value(1)>=40")
|
||||
assert_equal(r.filtered(ef).to_s, "('T',r0 100,200){1=>42,PropA=>17}")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue