git @ Cat's Eye Technologies Eightebed / d47edf8
All tests pass under Python 3. Chris Pressey 1 year, 3 months ago
3 changed file(s) with 27 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
5555 output = Popen([options.compiler, filename], stdout=PIPE).communicate()[0]
5656 if options.verbose:
5757 sys.stdout.write(output)
58 if output != '':
58 if output not in ('', b''):
5959 raise RuntimeError("Compilation failed!")
6060 if options.run:
6161 logger.info("Running...")
6262 output = Popen([a_out], stdout=PIPE).communicate()[0]
63 try:
64 # Python 2
65 output = unicode(output).encode('ascii')
66 except NameError:
67 # Python 3
68 output = output.decode('ascii')
6369 if options.clean:
6470 os.remove(filename)
6571 os.remove(a_out)
33 """
44 Test suite for (Python implementations of) the Eightebed programming language.
55 """
6
7
8 def expect_type_error(fun):
9 from .parser import TypeError
10 try:
11 fun()
12 except TypeError as e:
13 print('Traceback (most recent call last):')
14 print('...')
15 print('TypeError: {}'.format(e))
616
717
818 class Tests(object):
2636 ...
2737 KeyError: 'jim already declared'
2838
29 >>> parse_and_check(Tests.ptr_to_ptr)
39 >>> expect_type_error(lambda: parse_and_check(Tests.ptr_to_ptr))
3040 Traceback (most recent call last):
3141 ...
3242 TypeError: Pointer type must point to named type
3343
34 >>> parse_and_check(Tests.ptr_to_int)
44 >>> expect_type_error(lambda: parse_and_check(Tests.ptr_to_int))
3545 Traceback (most recent call last):
3646 ...
3747 TypeError: Pointer type must point to named type
3848
39 >>> parse_and_check(Tests.struct_within_struct)
49 >>> expect_type_error(lambda: parse_and_check(Tests.struct_within_struct))
4050 Traceback (most recent call last):
4151 ...
4252 TypeError: Structs may not contain other structs
4353
44 >>> parse_and_check(Tests.named_int)
54 >>> expect_type_error(lambda: parse_and_check(Tests.named_int))
4555 Traceback (most recent call last):
4656 ...
4757 TypeError: Only structs may be named
4858
49 >>> parse_and_check(Tests.dereference_outside_conditional)
59 >>> expect_type_error(lambda: parse_and_check(Tests.dereference_outside_conditional))
5060 Traceback (most recent call last):
5161 ...
5262 TypeError: Attempt to dereference jim in non-safe context
5363
54 >>> parse_and_check(Tests.dereference_outside_safe_area)
64 >>> expect_type_error(lambda: parse_and_check(Tests.dereference_outside_safe_area))
5565 Traceback (most recent call last):
5666 ...
5767 TypeError: Attempt to dereference jim in non-safe context
6070 >>> p is None
6171 False
6272
63 >>> parse_and_check(Tests.dereference_after_free)
73 >>> expect_type_error(lambda: parse_and_check(Tests.dereference_after_free))
6474 Traceback (most recent call last):
6575 ...
6676 TypeError: Attempt to dereference jim in non-safe context
0 #!/bin/sh
0 #!/bin/sh -x
11
2 src/8ebed2c.py -t -v
2 python2 src/8ebed2c.py -t || exit 1
3 python3 src/8ebed2c.py -t || exit 1