Add test cases to show the unsealed block in switch generation
@@ -542,8 +542,16 @@ block4:
#[test]
fn switch_seal_generated_blocks() {
- let keys = [0, 1, 2, 10, 11, 12, 20, 30, 40, 50];
+ let cases = &[vec![0, 1, 2], vec![0, 1, 2, 10, 11, 12, 20, 30, 40, 50]];
+ for case in cases {
+ for typ in &[types::I8, types::I16, types::I32, types::I64, types::I128] {
+ eprintln!("Testing {:?} with keys: {:?}", typ, case);
+ do_case(case, *typ);
+ }
+ }
+
+ fn do_case(keys: &[u128], typ: Type) {
let mut func = Function::new();
let mut builder_ctx = FunctionBuilderContext::new();
let mut builder = FunctionBuilder::new(&mut func, &mut builder_ctx);
@@ -564,7 +572,7 @@ block4:
builder.seal_block(root_block);
builder.switch_to_block(root_block);
- let val = builder.ins().iconst(types::I32, 1);
+ let val = builder.ins().iconst(typ, 1);
switch.emit(&mut builder, val, default_block);
for &block in case_blocks.iter().chain(std::iter::once(&default_block)) {
@@ -575,6 +583,7 @@ block4:
builder.finalize(); // Will panic if some blocks are not sealed
}
+ }
#[test]
fn switch_64bit() {
