From 93abbcfe564824cdb08bd44cb87bd56f93c1153e Mon Sep 17 00:00:00 2001 From: Jim Posen Date: Fri, 12 Jul 2019 10:30:11 +0200 Subject: [PATCH] Add gas injection unit test for correct else behavior. --- src/gas.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/gas.rs b/src/gas.rs index d068443..27aba65 100644 --- a/src/gas.rs +++ b/src/gas.rs @@ -914,4 +914,40 @@ mod tests { (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))) + "# + } }