diff options
author | Max Bernstein <[email protected]> | 2025-02-06 10:51:41 -0500 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2025-04-18 21:52:55 +0900 |
commit | acf9491215e12334e0ceadf1458eb9ba707d87b7 (patch) | |
tree | 1244b74a882f3197cdd13c304d45b643f9f3ff99 /zjit/src | |
parent | a45a85a58f16568a356bb12c6b9b3c4b9d7b59d1 (diff) |
Add assert for Function
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13131
Diffstat (limited to 'zjit/src')
-rw-r--r-- | zjit/src/lib.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/zjit/src/lib.rs b/zjit/src/lib.rs index dc9e597998..b86722fe79 100644 --- a/zjit/src/lib.rs +++ b/zjit/src/lib.rs @@ -19,19 +19,19 @@ pub struct InsnId(usize); pub struct BlockId(usize); // TODO: replace with VALUE -#[derive(Debug)] +#[derive(Debug, PartialEq)] enum RubyValue { Nil, } -#[derive(Debug)] +#[derive(Debug, PartialEq)] enum Insn { Param { idx: usize }, Const { val: RubyValue }, Return { val: InsnId }, } -#[derive(Debug)] +#[derive(Debug, PartialEq)] struct Block { params: Vec<InsnId>, insns: Vec<InsnId>, @@ -43,7 +43,7 @@ impl Block { } } -#[derive(Debug)] +#[derive(Debug, PartialEq)] struct Function { entry_block: BlockId, insns: Vec<Insn>, @@ -115,6 +115,14 @@ mod tests { RubyOpcode::Leave, ]; let function = to_ssa(&opcodes); - println!("zjit {function:?}"); + assert_eq!(function, Function { + entry_block: BlockId(0), + insns: vec![ + Insn::Const { val: RubyValue::Nil }, + Insn::Return { val: InsnId(0) }], + blocks: vec![ + Block { params: vec![], insns: vec![InsnId(0), InsnId(1)] } + ], + }); } } |