inflate L2 tests passing, fix TupleEnd stack history cleaning
This commit is contained in:
parent
66b42e2aa0
commit
c7c1fb19e2
2 changed files with 75 additions and 1 deletions
|
@ -112,7 +112,10 @@ fn inflate(mut flat_atoms: Vec<FlatAtom>) -> Vec<Atom> {
|
||||||
}
|
}
|
||||||
.last_mut()
|
.last_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.push(Atom::Tuple(popped))
|
.push({
|
||||||
|
stack_history.pop();
|
||||||
|
Atom::Tuple(popped)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
result.push(Atom::Tuple(popped))
|
result.push(Atom::Tuple(popped))
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,4 +83,75 @@ mod inflate {
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inflate_loop_l2() {
|
||||||
|
assert_eq!(
|
||||||
|
vec![Atom::Loop(
|
||||||
|
unsafe { NonZeroU8::new_unchecked(2) },
|
||||||
|
vec![Atom::Loop(
|
||||||
|
unsafe { NonZeroU8::new_unchecked(3) },
|
||||||
|
vec![Atom::Note(2), Atom::Note(3)]
|
||||||
|
)]
|
||||||
|
)],
|
||||||
|
inflate(vec![
|
||||||
|
FlatAtom::LoopStarts(unsafe { NonZeroU8::new_unchecked(2) }),
|
||||||
|
FlatAtom::LoopStarts(unsafe { NonZeroU8::new_unchecked(3) }),
|
||||||
|
FlatAtom::Note(2),
|
||||||
|
FlatAtom::Note(3),
|
||||||
|
FlatAtom::LoopEnds,
|
||||||
|
FlatAtom::LoopEnds
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inflate_tuple_l2() {
|
||||||
|
assert_eq!(
|
||||||
|
vec![Atom::Tuple(vec![Atom::Tuple(vec![
|
||||||
|
Atom::Note(2),
|
||||||
|
Atom::Note(3)
|
||||||
|
])])],
|
||||||
|
inflate(vec![
|
||||||
|
FlatAtom::TupleStarts,
|
||||||
|
FlatAtom::TupleStarts,
|
||||||
|
FlatAtom::Note(2),
|
||||||
|
FlatAtom::Note(3),
|
||||||
|
FlatAtom::TupleEnds,
|
||||||
|
FlatAtom::TupleEnds
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inflate_slope_l2() {
|
||||||
|
let instruction = || {
|
||||||
|
let parser = fasteval::Parser::new();
|
||||||
|
let mut slab = fasteval::Slab::new();
|
||||||
|
parser
|
||||||
|
.parse(FASTEVAL_INSTRUCTION, &mut slab.ps)
|
||||||
|
.unwrap()
|
||||||
|
.from(&slab.ps)
|
||||||
|
.compile(&slab.ps, &mut slab.cs)
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
vec![Atom::Slope(
|
||||||
|
SlopeModifier::Note,
|
||||||
|
instruction(),
|
||||||
|
vec![Atom::Slope(
|
||||||
|
SlopeModifier::Note,
|
||||||
|
instruction(),
|
||||||
|
vec![Atom::Note(2), Atom::Note(3)]
|
||||||
|
)]
|
||||||
|
)],
|
||||||
|
inflate(vec![
|
||||||
|
FlatAtom::SlopeStarts(SlopeModifier::Note, instruction()),
|
||||||
|
FlatAtom::SlopeStarts(SlopeModifier::Note, instruction()),
|
||||||
|
FlatAtom::Note(2),
|
||||||
|
FlatAtom::Note(3),
|
||||||
|
FlatAtom::SlopeEnds,
|
||||||
|
FlatAtom::SlopeEnds
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue