Ejemplo n.º 1
0
 def test_field_output(self):
     a = Field('a', 8)
     b = Sequence('b', [a])
     lookup = ResultParameters([b])
     self.assertEqual([Param('result', Param.OUT, EntryType(a))], lookup.get_params(a))
     self.assertEqual([Param('magic unknown param', Param.OUT, EntryType(a))], lookup.get_passed_variables(b, b.children[0]))
     self.assertEqual([Param('result', Param.OUT, EntryType(b))], lookup.get_params(b))
Ejemplo n.º 2
0
 def test_visible_common_in_hidden_context(self):
     a = Field('a', 8)
     b = Sequence('b:', [a])
     lookup = ResultParameters([a, b])
     self.assertEqual([Param('result', Param.OUT, EntryType(a))],
             lookup.get_params(a))
     self.assertEqual([], lookup.get_params(b))
     self.assertEqual([Local('unused a', EntryType(a))], lookup.get_locals(b))
     self.assertEqual([Param('unused a', Param.OUT, EntryType(a))],
         lookup.get_passed_variables(b, b.children[0]))
Ejemplo n.º 3
0
 def test_sequence_value(self):
     a = Field('a:', 8, Field.INTEGER)
     b = Sequence('b', [a], parse('${a:}'))
     lookup = ResultParameters([b])
     self.assertEqual([], lookup.get_params(a))
     self.assertEqual([Param('result', Param.OUT, EntryType(b))],
             lookup.get_params(b))
     self.assertEqual([], lookup.get_locals(a))
     self.assertEqual([], lookup.get_locals(b))
     self.assertEqual([], lookup.get_passed_variables(b, b.children[0]))
Ejemplo n.º 4
0
 def test_hidden_reference(self):
     # Test a visible common reference that is hidden through its reference
     # name. This is common for integers defined at the common level.
     #
     # Note that in this case 'b' won't have an output, because all of the
     # fields it defines are hidden, and so doesn't have a type itself.
     a = Field('a', 8, Field.INTEGER)
     b = Sequence('b', [Child('a:', a)])
     lookup = ResultParameters([a, b])
     self.assertEqual([Param('result', Param.OUT, EntryType(a))], lookup.get_params(a))
     self.assertEqual([], lookup.get_params(b))
     self.assertEqual([Local('unused a:', EntryType(a))], lookup.get_locals(b))
     self.assertEqual([Param('unused a:', Param.OUT, EntryType(a))], lookup.get_passed_variables(b, b.children[0]))