Skip to content

Commit 0773b68

Browse files
corona10ncw
authored andcommitted
parser: Update make_grammer_text.py
- Support auto-generated license header based on created time. - Add missed case when adding test cases #22
1 parent 2981ee9 commit 0773b68

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

parser/make_grammar_test.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sys
1212
import ast
13+
import datetime
1314
import subprocess
1415

1516
inp = [
@@ -57,6 +58,7 @@
5758
("[1,]", "eval"),
5859
("[1,2]", "eval"),
5960
("[1,2,]", "eval"),
61+
("[e for e in (1,2,3)]", "eval"),
6062

6163
# tuple
6264
("( a for a in ab )", "eval"),
@@ -375,6 +377,9 @@
375377
("a, b = *a", "exec"),
376378
("a = yield a", "exec"),
377379
('''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),
378383
('''f() = 1''', "exec", SyntaxError),
379384
('''lambda: x = 1''', "exec", SyntaxError),
380385
('''(a + b) = 1''', "exec", SyntaxError),
@@ -493,21 +498,26 @@ def escape(x):
493498
def main():
494499
"""Write grammar_data_test.go"""
495500
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
497507
498508
package parser
499509
500510
import (
501511
"github.com/go-python/gpython/py"
502512
)
503513
504-
var grammarTestData = []struct {
514+
var grammarTestData = []struct {{
505515
in string
506516
mode string
507517
out string
508518
exceptionType *py.Type
509519
errString string
510-
}{"""]
520+
}}{{""".format(year=year)]
511521
for x in inp:
512522
source, mode = x[:2]
513523
if len(x) > 2:

0 commit comments

Comments
 (0)