non_compliant_lexer.py 714 Bytes
Newer Older
1
2
# lexer tests for things that are not implemented, or have non-compliant behaviour

3
4
5
6
7
8
9
10
11
def test(code):
    try:
        exec(code)
        print('no Error')
    except SyntaxError:
        print('SyntaxError')
    except NotImplementedError:
        print('NotImplementedError')

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# uPy requires spaces between literal numbers and keywords, CPy doesn't
try:
    eval('1and 0')
except SyntaxError:
    print('SyntaxError')
try:
    eval('1or 0')
except SyntaxError:
    print('SyntaxError')
try:
    eval('1if 1else 0')
except SyntaxError:
    print('SyntaxError')
try:
    eval('1if 0else 0')
except SyntaxError:
    print('SyntaxError')
29
30
31

# unicode name escapes are not implemented
test('"\\N{LATIN SMALL LETTER A}"')