inflate mixed and panic tests failing
This commit is contained in:
parent
c7c1fb19e2
commit
d67f5efe48
1 changed files with 72 additions and 19 deletions
|
@ -1,12 +1,22 @@
|
|||
#[cfg(test)]
|
||||
mod inflate {
|
||||
use fasteval::Compiler;
|
||||
use lex::UP;
|
||||
use lex::{ON, UP};
|
||||
|
||||
use super::{super::*, inflate};
|
||||
|
||||
const FASTEVAL_INSTRUCTION: &str = "1-cos((PI*x)/2)";
|
||||
|
||||
fn instruction() -> 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)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inflate_flat() {
|
||||
assert_eq!(
|
||||
|
@ -60,15 +70,6 @@ mod inflate {
|
|||
|
||||
#[test]
|
||||
fn inflate_slope_l1() {
|
||||
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,
|
||||
|
@ -125,15 +126,6 @@ mod inflate {
|
|||
|
||||
#[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,
|
||||
|
@ -154,4 +146,65 @@ mod inflate {
|
|||
])
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixed() {
|
||||
assert_eq!(
|
||||
vec![Atom::Slope(
|
||||
SlopeModifier::Note,
|
||||
instruction(),
|
||||
vec![Atom::Slope(
|
||||
SlopeModifier::Length,
|
||||
instruction(),
|
||||
vec![
|
||||
Atom::Note(2),
|
||||
Atom::Tuple(vec![Atom::Rest, Atom::Note(6)]),
|
||||
Atom::Note(3),
|
||||
Atom::Loop(
|
||||
unsafe { NonZeroU8::new_unchecked(9) },
|
||||
vec![Atom::QuickModifier(QuickModifier::Pizz(ON)), Atom::Note(0)]
|
||||
)
|
||||
]
|
||||
)]
|
||||
)],
|
||||
inflate(vec![
|
||||
FlatAtom::SlopeStarts(SlopeModifier::Note, instruction()),
|
||||
FlatAtom::SlopeStarts(SlopeModifier::Length, instruction()),
|
||||
FlatAtom::Note(2),
|
||||
FlatAtom::TupleStarts,
|
||||
FlatAtom::Rest,
|
||||
FlatAtom::Note(6),
|
||||
FlatAtom::TupleEnds,
|
||||
FlatAtom::Note(3),
|
||||
FlatAtom::LoopStarts(unsafe { NonZeroU8::new_unchecked(9) }),
|
||||
FlatAtom::QuickModifier(QuickModifier::Pizz(ON)),
|
||||
FlatAtom::Note(0),
|
||||
FlatAtom::LoopEnds,
|
||||
FlatAtom::SlopeEnds,
|
||||
FlatAtom::SlopeEnds
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn mixed_panic() {
|
||||
inflate(vec![
|
||||
FlatAtom::SlopeStarts(SlopeModifier::Note, instruction()),
|
||||
FlatAtom::SlopeStarts(SlopeModifier::Length, instruction()),
|
||||
FlatAtom::Note(2),
|
||||
FlatAtom::TupleStarts,
|
||||
FlatAtom::Rest,
|
||||
FlatAtom::SlopeEnds, // mismatched slope end while in a tuple
|
||||
FlatAtom::Note(6),
|
||||
FlatAtom::TupleEnds,
|
||||
FlatAtom::Note(3),
|
||||
FlatAtom::LoopStarts(unsafe { NonZeroU8::new_unchecked(9) }),
|
||||
FlatAtom::QuickModifier(QuickModifier::Pizz(ON)),
|
||||
FlatAtom::Note(0),
|
||||
FlatAtom::LoopEnds,
|
||||
FlatAtom::SlopeEnds,
|
||||
FlatAtom::SlopeEnds,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue