Skip to content

Commit 9198567

Browse files
committed
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 b715616 commit 9198567

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎parser/make_grammar_test.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
importsys
1212
importast
13+
importdatetime
1314
importsubprocess
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
defmain():
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
forxininp:
512522
source, mode=x[:2]
513523
iflen(x) >2:

0 commit comments

Comments
(0)