• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ergoplatform / sigma-rust / 9822292740

06 Jul 2024 09:42PM UTC coverage: 78.938% (-1.6%) from 80.517%
9822292740

push

github

web-flow
Merge pull request #752 from SethDusek/optimizations

Optimizations

478 of 574 new or added lines in 119 files covered. (83.28%)

252 existing lines in 65 files now uncovered.

10794 of 13674 relevant lines covered (78.94%)

3.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/ergotree-interpreter/src/eval/extract_bytes_with_no_ref.rs
1
use ergotree_ir::mir::extract_bytes_with_no_ref::ExtractBytesWithNoRef;
2
use ergotree_ir::mir::value::Value;
3

4
use crate::eval::env::Env;
5
use crate::eval::Context;
6
use crate::eval::EvalError;
7
use crate::eval::Evaluable;
8

9
impl Evaluable for ExtractBytesWithNoRef {
10
    fn eval<'ctx>(
1✔
11
        &self,
12
        env: &mut Env<'ctx>,
13
        ctx: &Context<'ctx>,
14
    ) -> Result<Value<'ctx>, EvalError> {
15
        let input_v = self.input.eval(env, ctx)?;
1✔
16
        match input_v {
1✔
17
            Value::CBox(b) => Ok(b.bytes_without_ref()?.into()),
1✔
18
            _ => Err(EvalError::UnexpectedValue(format!(
×
UNCOV
19
                "Expected ExtractBytesWithNoRef input to be Value::CBox, got {0:?}",
×
UNCOV
20
                input_v
×
21
            ))),
22
        }
23
    }
24
}
25

26
#[allow(clippy::unwrap_used)]
27
#[cfg(test)]
28
mod tests {
29
    use super::*;
30
    use crate::eval::context::Context;
31
    use crate::eval::tests::eval_out;
32
    use ergotree_ir::mir::expr::Expr;
33
    use ergotree_ir::mir::global_vars::GlobalVars;
34
    use sigma_test_util::force_any_val;
35

36
    #[test]
37
    fn eval() {
38
        let e: Expr = ExtractBytesWithNoRef {
39
            input: Box::new(GlobalVars::SelfBox.into()),
40
        }
41
        .into();
42
        let ctx = force_any_val::<Context>();
43
        assert_eq!(
44
            eval_out::<Vec<i8>>(&e, &ctx),
45
            ctx.self_box.bytes_without_ref().unwrap()
46
        );
47
    }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc