def test_multiple_initializer(self): pb = TestMultipleInstantiationBlock()._elaborated_def_to_proto() self.assertEqual( edgir.AssignLit(['inner1', '(constr)container_float_param'], 3.0), pb.constraints["(init)inner1.(constr)container_float_param"]) self.assertEqual( edgir.AssignLit(['inner2', '(constr)container_float_param'], 3.0), pb.constraints["(init)inner2.(constr)container_float_param"])
def test_initializer(self): pb = TestSingleInitializerBlock()._elaborated_def_to_proto() self.assertEqual(len(pb.constraints.items()), 3) self.assertEqual( edgir.AssignLit(['bundle_port', 'float_param'], 42.0), pb.constraints["(init)bundle_port.float_param"]) self.assertEqual( edgir.AssignLit(['bundle_port', 'a', 'float_param'], 1.0), pb.constraints["(init)bundle_port.a.float_param"]) self.assertEqual( edgir.AssignLit(['bundle_port', 'b', 'float_param'], -1.0), pb.constraints["(init)bundle_port.b.float_param"])
def test_default_initializer(self): pb = TestDefaultBlock()._elaborated_def_to_proto() self.assertEqual(len(pb.constraints.items()), 1) self.assertEqual( edgir.AssignLit(['inner', '(constr)container_float_param'], 3.0), pb.constraints["(init)inner.(constr)container_float_param"])
def test_footprint(self): self.assertIn( edgir.AssignLit(['footprint_name'], 'Resistor_SMD:R_0603_1608Metric'), self.pb.constraints.values()) self.assertIn(edgir.AssignLit(['value'], '1k'), self.pb.constraints.values()) self.assertIn(edgir.AssignLit(['refdes_prefix'], 'R'), self.pb.constraints.values()) expected_pinning = edgir.Metadata() path = edgir.ValueExpr() path.ref.steps.add().name = 'port_1' expected_pinning.members.node['1'].bin_leaf = path.SerializeToString() path = edgir.ValueExpr() path.ref.steps.add().name = 'port_2' expected_pinning.members.node['2'].bin_leaf = path.SerializeToString() self.assertEqual(self.pb.meta.members.node['pinning'], expected_pinning)
def test_nested_initializer(self): pb = TestNestedBlock()._elaborated_def_to_proto() self.assertEqual(len(pb.constraints.items()), 5) self.assertEqual( edgir.AssignLit(['outer_bundle', 'float_param'], 21.0), pb.constraints["(init)outer_bundle.float_param"]) self.assertEqual( edgir.AssignLit(['outer_bundle', 'a', 'float_param'], 1.0), pb.constraints["(init)outer_bundle.a.float_param"]) self.assertEqual( edgir.AssignLit(['outer_bundle', 'b', 'float_param'], -1.0), pb.constraints["(init)outer_bundle.b.float_param"]) self.assertEqual( edgir.AssignLit(['inner', '(constr)container_float_param'], 62.0), pb.constraints["(init)inner.(constr)container_float_param"]) self.assertEqual( edgir.AssignLit(['inner', '(constr)float_param'], 31.0), pb.constraints["(init)inner.(constr)float_param"])