@@ -890,6 +890,7 @@ _Py_uop_symbols_test(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored))
890
890
_Py_uop_abstractcontext_init (ctx );
891
891
PyObject * val_42 = NULL ;
892
892
PyObject * val_43 = NULL ;
893
+ PyObject * val_big = NULL ;
893
894
PyObject * tuple = NULL ;
894
895
895
896
// Use a single 'sym' variable so copy-pasting tests is easier.
@@ -1020,16 +1021,46 @@ _Py_uop_symbols_test(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored))
1020
1021
TEST_PREDICATE (_Py_uop_sym_get_const (ctx , ref ) == Py_False , "truthiness is not False" );
1021
1022
TEST_PREDICATE (_Py_uop_sym_is_const (ctx , value ) == true, "value is not constant" );
1022
1023
TEST_PREDICATE (_Py_uop_sym_get_const (ctx , value ) == Py_True , "value is not True" );
1024
+
1025
+
1026
+ val_big = PyNumber_Lshift (_PyLong_GetOne (), PyLong_FromLong (66 ));
1027
+ if (val_big == NULL ) {
1028
+ goto fail ;
1029
+ }
1030
+
1031
+ JitOptRef ref_42 = _Py_uop_sym_new_const (ctx , val_42 );
1032
+ JitOptRef ref_big = _Py_uop_sym_new_const (ctx , val_big );
1033
+ JitOptRef ref_int = _Py_uop_sym_new_compact_int (ctx );
1034
+ TEST_PREDICATE (_Py_uop_sym_is_compact_int (ref_42 ), "42 is not a compact int" );
1035
+ TEST_PREDICATE (!_Py_uop_sym_is_compact_int (ref_big ), "(1 << 66) is a compact int" );
1036
+ TEST_PREDICATE (_Py_uop_sym_is_compact_int (ref_int ), "compact int is not a compact int" );
1037
+ TEST_PREDICATE (_Py_uop_sym_matches_type (ref_int , & PyLong_Type ), "compact int is not an int" );
1038
+
1039
+ _Py_uop_sym_set_type (ctx , ref_int , & PyLong_Type ); // Should have no effect
1040
+ TEST_PREDICATE (_Py_uop_sym_is_compact_int (ref_int ), "compact int is not a compact int after cast" );
1041
+ TEST_PREDICATE (_Py_uop_sym_matches_type (ref_int , & PyLong_Type ), "compact int is not an int after cast" );
1042
+
1043
+ _Py_uop_sym_set_type (ctx , ref_int , & PyFloat_Type ); // Should make it bottom
1044
+ TEST_PREDICATE (_Py_uop_sym_is_bottom (ref_int ), "compact int cast to float isn't bottom" );
1045
+
1046
+ ref_int = _Py_uop_sym_new_compact_int (ctx );
1047
+ _Py_uop_sym_set_const (ctx , ref_int , val_43 );
1048
+ TEST_PREDICATE (_Py_uop_sym_is_compact_int (ref_int ), "43 is not a compact int" );
1049
+ TEST_PREDICATE (_Py_uop_sym_matches_type (ref_int , & PyLong_Type ), "43 is not an int" );
1050
+ TEST_PREDICATE (_Py_uop_sym_get_const (ctx , ref_int ) == val_43 , "43 isn't 43" );
1051
+
1023
1052
_Py_uop_abstractcontext_fini (ctx );
1024
1053
Py_DECREF (val_42 );
1025
1054
Py_DECREF (val_43 );
1055
+ Py_DECREF (val_big );
1026
1056
Py_DECREF (tuple );
1027
1057
Py_RETURN_NONE ;
1028
1058
1029
1059
fail :
1030
1060
_Py_uop_abstractcontext_fini (ctx );
1031
1061
Py_XDECREF (val_42 );
1032
1062
Py_XDECREF (val_43 );
1063
+ Py_XDECREF (val_big );
1033
1064
Py_DECREF (tuple );
1034
1065
return NULL ;
1035
1066
}
0 commit comments