• 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.rs
1
use ergotree_ir::mir::extract_bytes::ExtractBytes;
2
use ergotree_ir::mir::value::Value;
3
use ergotree_ir::serialization::SigmaSerializable;
4

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

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

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

38
    #[test]
39
    fn eval() {
40
        let e: Expr = ExtractBytes {
41
            input: Box::new(GlobalVars::SelfBox.into()),
42
        }
43
        .into();
44
        let ctx = force_any_val::<Context>();
45
        assert_eq!(
46
            eval_out::<Vec<i8>>(&e, &ctx),
47
            ctx.self_box.sigma_serialize_bytes().unwrap().as_vec_i8()
48
        );
49
    }
50
}
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