FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gpython/ast/dump_test.go at main · go-python/gpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
go-python
/
gpython
Public
Notifications
You must be signed in to change notification settings
Fork
105
Star
1k
Code
Issues
49
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
gpython
/
ast
/
dump_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (35 loc) · 1.4 KB
Breadcrumbs
gpython
/
ast
/
dump_test.go
Copy path
File metadata and controls
39 lines (35 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2018 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.
package
ast
import
(
"testing"
"github.com/go-python/gpython/py"
)
func
TestDump
(
t
*
testing.
T
) {
for
_
,
test
:=
range
[]
struct
{
in
Ast
out
string
}{
{
nil
,
`<nil>`
},
{
&
Pass
{},
`Pass()`
},
{
&
Str
{
S
:
py
.
String
(
"potato"
)},
`Str(s='potato')`
},
{
&
Str
{
S
:
py
.
String
(
"potato"
)},
`Str(s='potato')`
},
{
&
Bytes
{
S
:
py
.
Bytes
(
"potato"
)},
`Bytes(s=b'potato')`
},
{
&
BinOp
{
Left
:
&
Str
{
S
:
py
.
String
(
"one"
)},
Op
:
Add
,
Right
:
&
Str
{
S
:
py
.
String
(
"two"
)}},
`BinOp(left=Str(s='one'), op=Add(), right=Str(s='two'))`
},
{
&
Module
{},
`Module(body=[])`
},
{
&
Module
{
Body
: []
Stmt
{
&
Pass
{}}},
`Module(body=[Pass()])`
},
{
&
Module
{
Body
: []
Stmt
{
&
ExprStmt
{
Value
:
&
Tuple
{}}}},
`Module(body=[Expr(value=Tuple(elts=[], ctx=UnknownExprContext(0)))])`
},
{
&
NameConstant
{
Value
:
py
.
True
},
`NameConstant(value=True)`
},
{
&
Name
{
Id
:
Identifier
(
"hello"
),
Ctx
:
Load
},
`Name(id='hello', ctx=Load())`
},
{
&
ListComp
{
Elt
:
&
Str
{
S
:
py
.
String
(
"potato"
)},
Generators
: []
Comprehension
{{
Target
:
&
Name
{
Id
:
Identifier
(
"hello"
),
Ctx
:
Load
},
}}},
`ListComp(elt=Str(s='potato'), generators=[comprehension(target=Name(id='hello', ctx=Load()), iter=None, ifs=[])])`
},
} {
out
:=
Dump
(
test
.
in
)
if
out
!=
test
.
out
{
t
.
Errorf
(
"Dump(%#v) got %q expected %q"
,
test
.
in
,
out
,
test
.
out
)
}
}
}
Back
|
FazBrowse Home
|
New Git URL