mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-29 22:51:56 +00:00
const test cases
This commit is contained in:
BIN
res/cases/v1/const.wasm
Normal file
BIN
res/cases/v1/const.wasm
Normal file
Binary file not shown.
12
res/cases/v1/const.wast
Normal file
12
res/cases/v1/const.wast
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
(module
|
||||||
|
(type (;0;) (func (result i32)))
|
||||||
|
(func (;0;) (type 0) (result i32)
|
||||||
|
i32.const 1024
|
||||||
|
i32.const 2048
|
||||||
|
i32.const 4096
|
||||||
|
i32.const 8192
|
||||||
|
i32.const 16384
|
||||||
|
i32.const 32767
|
||||||
|
return
|
||||||
|
)
|
||||||
|
)
|
@ -238,4 +238,20 @@ mod integration_tests {
|
|||||||
"There should be equal amount of function bodies before and after serialization"
|
"There should be equal amount of function bodies before and after serialization"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn const_() {
|
||||||
|
use super::super::Opcode::*;
|
||||||
|
|
||||||
|
let module = deserialize_file("./res/cases/v1/const.wasm").expect("Should be deserialized");
|
||||||
|
let func = &module.code_section().expect("Code section to exist").bodies()[0];
|
||||||
|
assert_eq!(func.code().elements().len(), 8);
|
||||||
|
|
||||||
|
assert_eq!(I32Const(1024), func.code().elements()[0]);
|
||||||
|
assert_eq!(I32Const(2048), func.code().elements()[1]);
|
||||||
|
assert_eq!(I32Const(4096), func.code().elements()[2]);
|
||||||
|
assert_eq!(I32Const(8192), func.code().elements()[3]);
|
||||||
|
assert_eq!(I32Const(16384), func.code().elements()[4]);
|
||||||
|
assert_eq!(I32Const(32767), func.code().elements()[5]);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Collection of opcodes (usually inside a block section).
|
/// Collection of opcodes (usually inside a block section).
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Opcodes(Vec<Opcode>);
|
pub struct Opcodes(Vec<Opcode>);
|
||||||
|
|
||||||
impl Opcodes {
|
impl Opcodes {
|
||||||
@ -88,7 +88,7 @@ impl Deserialize for InitExpr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Opcode
|
/// Opcode
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum Opcode {
|
pub enum Opcode {
|
||||||
Unreachable,
|
Unreachable,
|
||||||
|
Reference in New Issue
Block a user