2 # Code released under a free software compatible license. See LICENSE for more
4 # Original author: Nido Media
19 whitespace
= re
.compile("^\s*$")
20 entscan
= re
.compile(".*\.ent.*")
21 endscan
= re
.compile(".*\.end.*")
23 class testReader(unittest
.TestCase
):
25 self
.testfile
= "../code/basic_file.s"
27 def testReading(self
):
29 block_structure
= reader
.reader(self
.testfile
)
32 for tuple in block_structure
:
33 if tuple[0] == "block":
36 for block
in block_list
:
37 self
.assertTrue(block
.label
not in used_labels
, "No double labels!")
38 used_labels
.append(block
.label
)
40 self
.assertTrue(block
.jump
, "This block has no jump! Not even a fake one")
42 # only test blocks which have instructions
43 if len(block
.instructions
) > 0:
44 for line
in block
.instructions
:
45 line
= line
.regex_match
.group()
47 # There shall be no .ent and .end in the code
48 self
.assertFalse( entscan
.match(line
), "Found .ent!")
49 self
.assertFalse( endscan
.match(line
), "Found .end!")
52 if __name__
== '__main__':