Пример #1
0
    def test_resolve_multiple_defines(self):
        """second easiest test, this one requires multiple passes of the
        replacement string"""
        buf = "\n\n\
              `define B 1\n\
              `define A `B\n\
              module test ();\n\
              endmodule"

        define_dict = preprocessor.generate_define_table(buf, debug=False)
        result = preprocessor.resolve_defines("`B:`A", define_dict, debug=False)
        self.assertEqual(result, '1:1')
Пример #2
0
    def test_complicated_string(self):
        """Hardest test of all, filled with multiple replacements and
        all of the pre-processing techniques"""
        buf = "\n\n\
              `define B 2 \n\
              `define A `B \n\
              `define C 4 \n\
              module test ();\n\
              endmodule"

        define_dict = preprocessor.generate_define_table(buf, debug=False)
        result = preprocessor.resolve_defines("val[(`A * `B * `C):((`C)-(`A))]", define_dict, debug = self.dbg)
        result = preprocessor.evaluate_range(result, define_dict, debug=False)
        #print "result: %s" % result

        self.assertEqual(result, "val[16:2]")
Пример #3
0
 def test_resolve_non_wsp_define(self):
     """First test to see if the system will replace a define that isn't separated by whitespaces"""
     define_dict = {'TEST_DEFINE':1}
     result = preprocessor.resolve_defines("`TEST_DEFINE:0", define_dict, debug = self.dbg)
     self.assertEqual(result, '1:0')
Пример #4
0
 def test_resolve_one_define(self):
     """First test to see if the system will replace a define"""
     define_dict = {'TEST_DEFINE':1}
     result = preprocessor.resolve_defines("`TEST_DEFINE", define_dict, debug = self.dbg)
     self.assertEqual(int(result, 10), 1)