From 91985676c19ee96b6113e1ed3cd4ef4fb0e664f3 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 24 Nov 2018 16:43:48 +0900 Subject: [PATCH] parser: Update make_grammer_text.py - Support auto-generated license header based on created time. - Add missed case when adding test cases https://github.com/go-python/gpython/pull/22 --- parser/make_grammar_test.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/parser/make_grammar_test.py b/parser/make_grammar_test.py index c14f1a9f..d354e43a 100755 --- a/parser/make_grammar_test.py +++ b/parser/make_grammar_test.py @@ -10,6 +10,7 @@ import sys import ast +import datetime import subprocess inp = [ @@ -57,6 +58,7 @@ ("[1,]", "eval"), ("[1,2]", "eval"), ("[1,2,]", "eval"), + ("[e for e in (1,2,3)]", "eval"), # tuple ("( a for a in ab )", "eval"), @@ -375,6 +377,9 @@ ("a, b = *a", "exec"), ("a = yield a", "exec"), ('''a.b = 1''', "exec"), + ("[e for e in [1, 2, 3]] = 3", "exec", SyntaxError), + ("{e for e in [1, 2, 3]} = 3", "exec", SyntaxError), + ("{e: e**2 for e in [1, 2, 3]} = 3", "exec", SyntaxError), ('''f() = 1''', "exec", SyntaxError), ('''lambda: x = 1''', "exec", SyntaxError), ('''(a + b) = 1''', "exec", SyntaxError), @@ -493,7 +498,12 @@ def escape(x): def main(): """Write grammar_data_test.go""" path = "grammar_data_test.go" - out = ["""// Test data generated by make_grammar_test.py - do not edit + year = datetime.datetime.now().year + out = ["""// Copyright {year} The go-python Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test data generated by make_grammar_test.py - do not edit package parser @@ -501,13 +511,13 @@ def main(): "github.com/go-python/gpython/py" ) -var grammarTestData = []struct { +var grammarTestData = []struct {{ in string mode string out string exceptionType *py.Type errString string -}{"""] +}}{{""".format(year=year)] for x in inp: source, mode = x[:2] if len(x) > 2: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy