mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 15:08:54 +03:00
[jets] add mug test
This commit is contained in:
parent
331336f56b
commit
171da85f6f
@ -1,7 +1,5 @@
|
||||
use crate::interpreter::raw_slot;
|
||||
use crate::jets_math::*;
|
||||
use crate::mem::NockStack;
|
||||
use crate::mug::mug;
|
||||
use crate::noun::Noun;
|
||||
use ares_macros::tas;
|
||||
|
||||
@ -58,8 +56,3 @@ pub fn get_jet_test_mode(jet_name: Noun) -> bool {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn jet_mug(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
let arg = raw_slot(subject, 6);
|
||||
Ok(mug(stack, arg).as_noun())
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::interpreter::raw_slot;
|
||||
use crate::jets::{JetErr, JetErr::*};
|
||||
use crate::mem::NockStack;
|
||||
use crate::mug::mug;
|
||||
use crate::noun::{Atom, DirectAtom, IndirectAtom, Noun, D, DIRECT_MAX, NO, T, YES};
|
||||
/** Math jets
|
||||
*
|
||||
@ -379,6 +380,11 @@ pub fn jet_rsh(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn jet_mug(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
|
||||
let arg = raw_slot(subject, 6);
|
||||
Ok(mug(stack, arg).as_noun())
|
||||
}
|
||||
|
||||
/** Extract the bloq and step from a bite */
|
||||
fn bite(a: Noun) -> Result<(Atom, Atom), ()> {
|
||||
if let Ok(cell) = a.as_cell() {
|
||||
@ -854,4 +860,25 @@ mod tests {
|
||||
let res = A(s, &ubig!(0xdeadbeef12345678fedcba98));
|
||||
assert_jet(s, jet_cut, sam, res);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mug() {
|
||||
let ref mut s = init();
|
||||
let (a0, a24, a63, a96, a128) = atoms(s);
|
||||
assert_jet(s, jet_mug, a0, D(0x79ff04e8));
|
||||
assert_jet(s, jet_mug, a24, D(0x69d59d90));
|
||||
assert_jet(s, jet_mug, a63, D(0x7a9f252e));
|
||||
assert_jet(s, jet_mug, a96, D(0x2aa4c8fb));
|
||||
assert_jet(s, jet_mug, a128, D(0x44fb2c0c));
|
||||
let sam = T(s, &[a128, a128]);
|
||||
assert_jet(s, jet_mug, sam, D(0x61c0ea5c));
|
||||
let sam = T(s, &[a96, a128]);
|
||||
assert_jet(s, jet_mug, sam, D(0x20fb143f));
|
||||
let sam = T(s, &[a0, a0]);
|
||||
assert_jet(s, jet_mug, sam, D(0x192f5588));
|
||||
let sam = T(s, &[a0, a24, a63, a96, a128]);
|
||||
let sam = T(s, &[sam, a0, a24, a63, a96, a128]);
|
||||
let sam = T(s, &[sam, a0, a24, a63, a96, a128]);
|
||||
assert_jet(s, jet_mug, sam, D(0x7543cac7));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user