FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/integration_tests/enum_06.py at main · sak-codes/lpython · GitHub
sak-codes
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lpython
/
integration_tests
/
enum_06.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (30 loc) · 893 Bytes
Breadcrumbs
lpython
/
integration_tests
/
enum_06.py
Copy path
File metadata and controls
35 lines (30 loc) · 893 Bytes
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
from
ltypes
import
i32
,
dataclass
,
f64
from
numpy
import
empty
from
enum
import
Enum
class
Color
(
Enum
):
RED
:
i32
=
0
GREEN
:
i32
=
1
BLUE
:
i32
=
2
PINK
:
i32
=
3
WHITE
:
i32
=
4
YELLOW
:
i32
=
5
@
dataclass
class
Truck
:
horsepower
:
f64
seats
:
i32
price
:
f64
color
:
Color
def
print_Truck
(
car
:
Truck
):
print
(
car
.
horsepower
,
car
.
seats
,
car
.
price
,
car
.
color
.
name
)
def
test_enum_as_struct_member
():
cars
:
Truck
[
3
]
=
empty
(
3
,
dtype
=
Truck
)
cars
[
0
]
=
Truck
(
700.0
,
4
,
100000.0
,
Color
.
RED
)
cars
[
1
]
=
Truck
(
800.0
,
5
,
200000.0
,
Color
.
BLUE
)
cars
[
2
]
=
Truck
(
400.0
,
4
,
50000.0
,
Color
.
WHITE
)
print_Truck
(
cars
[
0
])
print_Truck
(
cars
[
1
])
print_Truck
(
cars
[
2
])
assert
cars
[
2
].
color
.
value
==
Color
.
WHITE
.
value
assert
cars
[
1
].
color
.
value
==
Color
.
BLUE
.
value
assert
cars
[
0
].
color
.
value
==
Color
.
RED
.
value
test_enum_as_struct_member
()
Back
|
FazBrowse Home
|
New Git URL