File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed
numba_dpex/tests/experimental/IntEnumLiteral Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2023 Intel Corporation
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ from enum import IntEnum
6+
7+ import pytest
8+
9+ from numba_dpex .core .exceptions import IllegalIntEnumLiteralValueError
10+ from numba_dpex .experimental import IntEnumLiteral
11+ from numba_dpex .experimental .flag_enum import FlagEnum
12+
13+
14+ def test_intenumliteral_creation ():
15+ """Tests the creation of an IntEnumLiteral type."""
16+
17+ class DummyFlags (FlagEnum ):
18+ DUMMY = 0
19+
20+ try :
21+ IntEnumLiteral (DummyFlags .DUMMY )
22+ except :
23+ pytest .fail ("Unexpected failure in IntEnumLiteral initialization" )
24+
25+ with pytest .raises (IllegalIntEnumLiteralValueError ):
26+ IntEnumLiteral (0 )
27+
28+ with pytest .raises (IllegalIntEnumLiteralValueError ):
29+
30+ class SomeKindOfUnknownEnum (IntEnum ):
31+ UNKNOWN_FLAG = 1
32+
33+ IntEnumLiteral (SomeKindOfUnknownEnum .UNKNOWN_FLAG )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2023 Intel Corporation
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ import pytest
6+ from numba .core .datamodel import default_manager
7+
8+ from numba_dpex .core .datamodel .models import dpex_data_model_manager
9+ from numba_dpex .experimental import IntEnumLiteral
10+ from numba_dpex .experimental .flag_enum import FlagEnum
11+ from numba_dpex .experimental .models import exp_dmm
12+
13+
14+ def test_data_model_registration ():
15+ """Tests that the IntEnumLiteral type is only registered with the
16+ DpexExpKernelTargetContext target.
17+ """
18+
19+ class DummyFlags (FlagEnum ):
20+ DUMMY = 0
21+
22+ dummy = IntEnumLiteral (DummyFlags .DUMMY )
23+
24+ with pytest .raises (KeyError ):
25+ default_manager .lookup (dummy )
26+
27+ with pytest .raises (KeyError ):
28+ dpex_data_model_manager .lookup (dummy )
29+
30+ try :
31+ exp_dmm .lookup (dummy )
32+ except :
33+ pytest .fail (
34+ "IntEnumLiteral type lookup failed in experimental "
35+ "data model manager"
36+ )
You can’t perform that action at this time.
0 commit comments