OILS / opy / gold / genexpr.py View on Github | oilshell.org

29 lines, 11 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3"""
4Test for generator expressions.
5"""
6
7def MakeLookup(p):
8 #return dict([(pat, tok) for _, pat, tok in p])
9 # Something is broken about how we compile this...
10 # Difference in compilation is SETUP_LOOP. So CPython handle this fine,
11 # but bytern doesn't.
12 return dict((pat, tok) for _, pat, tok in p)
13
14 # This should be an error but isn't. Looks like it's not compiled
15 # correctly.
16 #return list(i for (i, j) in p)
17
18fake_pairs = [
19 (False, '-a', 0),
20 (False, '-b', 1),
21 (False, '-c', 2),
22 #(False, '-d', 3),
23 #(False, '-e', 4),
24 #(False, '-f', 5),
25]
26#lookup = MakeLookup(id_kind.ID_SPEC.LexerPairs(Kind.BoolUnary))
27lookup = MakeLookup(fake_pairs)
28print('LOOKUP ***************', len(lookup))
29print(lookup)