mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-03-15 19:20:48 +00:00
Add gas injection unit test for correct else behavior.
This commit is contained in:
parent
ed7f31ec20
commit
93abbcfe56
36
src/gas.rs
36
src/gas.rs
@ -914,4 +914,40 @@ mod tests {
|
|||||||
(get_global 0)))
|
(get_global 0)))
|
||||||
"#
|
"#
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_gas_counter_injection! {
|
||||||
|
name = branch_from_if_not_else;
|
||||||
|
input = r#"
|
||||||
|
(module
|
||||||
|
(func (result i32)
|
||||||
|
(get_global 0)
|
||||||
|
(block
|
||||||
|
(get_global 0)
|
||||||
|
(if
|
||||||
|
(then (br 1))
|
||||||
|
(else (br 0)))
|
||||||
|
(get_global 0)
|
||||||
|
(drop))
|
||||||
|
(get_global 0)))
|
||||||
|
"#;
|
||||||
|
expected = r#"
|
||||||
|
(module
|
||||||
|
(func (result i32)
|
||||||
|
(call 0 (i32.const 5))
|
||||||
|
(get_global 0)
|
||||||
|
(block
|
||||||
|
(get_global 0)
|
||||||
|
(if
|
||||||
|
(then
|
||||||
|
(call 0 (i32.const 1))
|
||||||
|
(br 1))
|
||||||
|
(else
|
||||||
|
(call 0 (i32.const 1))
|
||||||
|
(br 0)))
|
||||||
|
(call 0 (i32.const 2))
|
||||||
|
(get_global 0)
|
||||||
|
(drop))
|
||||||
|
(get_global 0)))
|
||||||
|
"#
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user