|
10 | 10 |
|
11 | 11 | import sys
|
12 | 12 | import ast
|
| 13 | +import datetime |
13 | 14 | import subprocess
|
14 | 15 |
|
15 | 16 | inp = [
|
|
57 | 58 | ("[1,]", "eval"),
|
58 | 59 | ("[1,2]", "eval"),
|
59 | 60 | ("[1,2,]", "eval"),
|
| 61 | + ("[e for e in (1,2,3)]", "eval"), |
60 | 62 |
|
61 | 63 | # tuple
|
62 | 64 | ("( a for a in ab )", "eval"),
|
|
375 | 377 | ("a, b = *a", "exec"),
|
376 | 378 | ("a = yield a", "exec"),
|
377 | 379 | ('''a.b = 1''', "exec"),
|
| 380 | + ("[e for e in [1, 2, 3]] = 3", "exec", SyntaxError), |
| 381 | + ("{e for e in [1, 2, 3]} = 3", "exec", SyntaxError), |
| 382 | + ("{e: e**2 for e in [1, 2, 3]} = 3", "exec", SyntaxError), |
378 | 383 | ('''f() = 1''', "exec", SyntaxError),
|
379 | 384 | ('''lambda: x = 1''', "exec", SyntaxError),
|
380 | 385 | ('''(a + b) = 1''', "exec", SyntaxError),
|
@@ -493,21 +498,26 @@ def escape(x):
|
493 | 498 | def main():
|
494 | 499 | """Write grammar_data_test.go"""
|
495 | 500 | path = "grammar_data_test.go"
|
496 |
| - out = ["""// Test data generated by make_grammar_test.py - do not edit |
| 501 | + year = datetime.datetime.now().year |
| 502 | + out = ["""// Copyright {year} The go-python Authors. All rights reserved. |
| 503 | +// Use of this source code is governed by a BSD-style |
| 504 | +// license that can be found in the LICENSE file. |
| 505 | +
|
| 506 | +// Test data generated by make_grammar_test.py - do not edit |
497 | 507 |
|
498 | 508 | package parser
|
499 | 509 |
|
500 | 510 | import (
|
501 | 511 | "github.com/go-python/gpython/py"
|
502 | 512 | )
|
503 | 513 |
|
504 |
| -var grammarTestData = []struct { |
| 514 | +var grammarTestData = []struct {{ |
505 | 515 | in string
|
506 | 516 | mode string
|
507 | 517 | out string
|
508 | 518 | exceptionType *py.Type
|
509 | 519 | errString string
|
510 |
| -}{"""] |
| 520 | +}}{{""".format(year=year)] |
511 | 521 | for x in inp:
|
512 | 522 | source, mode = x[:2]
|
513 | 523 | if len(x) > 2:
|
|
0 commit comments