@@ -1463,35 +1463,43 @@ mod test {
1463
1463
}
1464
1464
1465
1465
#[ rstest]
1466
- fn test_exec_widen ( int_exec_ctx : TestContext ) {
1467
- let from: u8 = 1 ;
1466
+ #[ case( -127 ) ]
1467
+ #[ case( -1 ) ]
1468
+ #[ case( 0 ) ]
1469
+ #[ case( 1 ) ]
1470
+ #[ case( 127 ) ]
1471
+ fn test_exec_widen ( int_exec_ctx : TestContext , #[ case] num : i16 ) {
1472
+ let from: u8 = 3 ;
1468
1473
let to: u8 = 6 ;
1469
1474
let ty = INT_TYPES [ to as usize ] . clone ( ) ;
1470
- let input = ConstInt :: new_u ( from, 1 ) . unwrap ( ) ;
1471
1475
1472
- let ext_op = int_ops:: EXTENSION
1473
- . instantiate_extension_op (
1474
- "iwiden_u" . as_ref ( ) ,
1475
- [ u64:: from ( from) . into ( ) , u64:: from ( to) . into ( ) ] ,
1476
- )
1477
- . unwrap ( ) ;
1476
+ if num >= 0 {
1477
+ let input = ConstInt :: new_u ( from, num as u64 ) . unwrap ( ) ;
1478
1478
1479
- let hugr = test_int_op_with_results :: < 1 > ( ext_op, to, Some ( [ input] ) , ty. clone ( ) ) ;
1479
+ let ext_op = int_ops:: EXTENSION
1480
+ . instantiate_extension_op (
1481
+ "iwiden_u" . as_ref ( ) ,
1482
+ [ ( from as u64 ) . into ( ) , ( to as u64 ) . into ( ) ] ,
1483
+ )
1484
+ . unwrap ( ) ;
1480
1485
1481
- assert_eq ! ( int_exec_ctx. exec_hugr_u64( hugr, "main" ) , 1 ) ;
1486
+ let hugr = test_int_op_with_results :: < 1 > ( ext_op, to, Some ( [ input] ) , ty. clone ( ) ) ;
1487
+
1488
+ assert_eq ! ( int_exec_ctx. exec_hugr_u64( hugr, "main" ) , num as u64 ) ;
1489
+ }
1482
1490
1483
- let input = ConstInt :: new_s ( from, 1 ) . unwrap ( ) ;
1491
+ let input = ConstInt :: new_s ( from, num as i64 ) . unwrap ( ) ;
1484
1492
1485
1493
let ext_op = int_ops:: EXTENSION
1486
1494
. instantiate_extension_op (
1487
1495
"iwiden_s" . as_ref ( ) ,
1488
- [ u64 :: from ( from) . into ( ) , u64 :: from ( to) . into ( ) ] ,
1496
+ [ ( from as u64 ) . into ( ) , ( to as u64 ) . into ( ) ] ,
1489
1497
)
1490
1498
. unwrap ( ) ;
1491
1499
1492
1500
let hugr = test_int_op_with_results :: < 1 > ( ext_op, to, Some ( [ input] ) , ty. clone ( ) ) ;
1493
1501
1494
- assert_eq ! ( int_exec_ctx. exec_hugr_u64 ( hugr, "main" ) , 1 ) ;
1502
+ assert_eq ! ( int_exec_ctx. exec_hugr_i64 ( hugr, "main" ) , num as i64 ) ;
1495
1503
}
1496
1504
1497
1505
#[ rstest]
0 commit comments