mirror of
https://github.com/urbit/ares.git
synced 2024-11-26 09:57:56 +03:00
[jets] add met jet
This commit is contained in:
parent
956045a91d
commit
8946568a08
@ -43,6 +43,7 @@ pub fn get_jet(jet_name: Noun) -> Result<Jet, ()> {
|
||||
tas!(b"lsh") => Ok(jet_lsh),
|
||||
tas!(b"rsh") => Ok(jet_rsh),
|
||||
tas!(b"cut") => Ok(jet_cut),
|
||||
tas!(b"met") => Ok(jet_met),
|
||||
tas!(b"mug") => Ok(jet_mug),
|
||||
_ => {
|
||||
// eprintln!("Unknown jet: {:?}", jet_name);
|
||||
|
@ -380,6 +380,17 @@ pub fn jet_rsh(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn jet_met(_stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
let arg = raw_slot(subject, 6);
|
||||
let bloq = raw_slot(arg, 2).as_direct()?.data() as usize;
|
||||
if bloq >= 64 {
|
||||
return Err(Deterministic);
|
||||
}
|
||||
let a = raw_slot(arg, 3).as_atom()?;
|
||||
|
||||
Ok(D(met(bloq, a) as u64))
|
||||
}
|
||||
|
||||
pub fn jet_mug(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
let arg = raw_slot(subject, 6);
|
||||
Ok(mug(stack, arg).as_noun())
|
||||
@ -861,6 +872,20 @@ mod tests {
|
||||
assert_jet(s, jet_cut, sam, res);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_jet_met() {
|
||||
let ref mut s = init();
|
||||
let (a0, a24, _a63, _a96, a128) = atoms(s);
|
||||
let sam = T(s, &[a0, a0]);
|
||||
assert_jet(s, jet_met, sam, D(0));
|
||||
let sam = T(s, &[a0, a24]);
|
||||
assert_jet(s, jet_met, sam, D(24));
|
||||
let sam = T(s, &[D(3), a24]);
|
||||
assert_jet(s, jet_met, sam, D(3));
|
||||
let sam = T(s, &[D(1), a128]);
|
||||
assert_jet(s, jet_met, sam, D(64));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mug() {
|
||||
let ref mut s = init();
|
||||
|
Loading…
Reference in New Issue
Block a user