Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Derive.DeriveTest

Contents

Description

Utility functions for derive tests.

Synopsis

Documentation

signal_interpolate :: RealTime.RealTime -> Signal.Y -> RealTime.RealTime -> Signal.Y -> [(RealTime.RealTime, Signal.Y)] Source #

Simulate the linear interpolate call, to check deriver output that involves that particular call.

Drops the first sample to make this match output from the derive call interpolators.

run

run_ :: Ui.State -> Deriver a -> Either String (a, State, [Log.Msg]) Source #

Run without a fake stack.

extract_run :: (a -> b) -> Either String (a, State, [Log.Msg]) -> Either String b Source #

perform

perform_result :: (Stream.Stream Score.Event -> (a, [Log.Msg])) -> Result -> (a, [String]) Source #

Chain a perform from a Derive.Result.

derive

derive_tracks_linear :: Text -> [UiTest.TrackSpec] -> Result Source #

Derive tracks but with a linear skeleton. Good for testing note transformers since the default skeleton parsing won't create those.

derive_tracks_setup :: Setup -> Text -> [UiTest.TrackSpec] -> Result Source #

Variant that lets you run setup on various states.

derive block variations

derive_blocks :: [UiTest.BlockSpec] -> Result Source #

Create multiple blocks, and derive the first one.

derive_block_setup :: Setup -> Ui.State -> Id.BlockId -> Result Source #

Derive a block with the testing environ.

derive_dump :: [MidiInst.Synth] -> Simple.State -> Id.BlockId -> Result Source #

Derive the results of a Cmd.Repl.LDebug.dump_block.

derive_block_standard :: Setup -> Cmd.State -> Cache -> ScoreDamage -> Ui.State -> Id.BlockId -> Result Source #

Derive a block in the same way that the app does.

cmd

run_cmd :: CallStack.Stack => Ui.State -> Cmd.State -> Cmd.CmdId a -> a Source #

CmdTest also has this, but I can't import it because it imports DeriveTest.

setup

data SetupA a Source #

This file only ever uses Setup, but it loses polymorphism. To reuse with_* functions in a polymorphic way, I can use SetupA and pull them back out with setup_deriver.

Instances

Monoid (SetupA a) # 

Methods

mempty :: SetupA a #

mappend :: SetupA a -> SetupA a -> SetupA a #

mconcat :: [SetupA a] -> SetupA a #

setup_ui

with_linear :: Setup Source #

Set the skeleton of the tracks to be linear, i.e. each track is the child of the one to the left. This overrides the default behaviour of figuring out a skeleton by making note tracks start their own branches.

with_ruler :: Id.BlockId -> Ruler.Ruler -> Setup Source #

Set the ruler on the given block.

setup_deriver

modify_constant :: (Constant -> Constant) -> SetupA a Source #

I'm not really supposed to do this, but should be *mostly* ok for tests. It's not entirely ok because some values are baked in to e.g. lookup functions.

modify_dynamic :: (Dynamic -> Dynamic) -> Deriver () Source #

Not supposed to do this in general, but it's ok for tests.

setup multiple

with_synths :: UiConfig.Allocations -> [MidiInst.Synth] -> Setup Source #

Derive with a bit of a real instrument db. Useful for testing instrument calls.

merge_allocs :: CallStack.Stack => [MidiInst.Synth] -> UiConfig.Allocations -> UiConfig.Allocations Source #

Merge the incomplete Allocations with the Patch defaults. Crash if it doesn't like you. TODO unused... maybe I don't really need this?

with_patch :: (MidiInst.Patch -> MidiInst.Patch) -> Text -> Setup Source #

Add a single instrument with a MIDI patch.

allocs_from_db :: Cmd.InstrumentDb -> Simple.Allocations -> UiConfig.Allocations Source #

Use the db to infer Patch.Settings for the allocations. The simple version doesn't record the Patch.config_settings, so I get the defaults.

type SimpleAllocations = [(Text, Text)] Source #

A further-simplified version of Simple.Allocations for tests: [(Instrument, Qualified)]

lookup_settings :: Cmd.InstrumentDb -> InstTypes.Qualified -> Maybe Patch.Settings Source #

This uses patch_defaults for settings, since I don't have a config.

defaults

cmd_config :: Cmd.InstrumentDb -> Cmd.Config Source #

Config to initialize the Cmd.State.

instrument defaults

extract

log msgs

trace_logs :: [Log.Msg] -> a -> a Source #

trace_low_prio :: [Log.Msg] -> [Log.Msg] Source #

Filter out low-priority logs and trace them.

interesting_log :: Log.Msg -> Bool Source #

Tests generally shouldn't depend on logs below a certain priority since those don't indicate anything interesting.

extract

extract :: (Score.Event -> a) -> Result -> ([a], [String]) Source #

extract_levents :: (a -> b) -> [LEvent.LEvent a] -> ([b], [String]) Source #

e_nns :: CallStack.Stack => Score.Event -> [(RealTime.RealTime, Pitch.NoteNumber)] Source #

Like e_nns_errors, but throw an exception if there are errors. Also drops duplicate samples for reasons described in unsignal_unique.

e_nn :: Score.Event -> Maybe Pitch.NoteNumber Source #

Like Score.initial_nn, except it transposes the pitch so you see the final value.

e_nns_rounded :: Score.Event -> [(RealTime.RealTime, Pitch.NoteNumber)] Source #

Like e_nns, but round to cents to make comparison easier.

e_nns_errors :: Score.Event -> ([(RealTime.RealTime, Pitch.NoteNumber)], [String]) Source #

Extract pitch signal and any errors flattening it.

e_note :: Score.Event -> (RealTime.RealTime, RealTime.RealTime, String) Source #

(start, dur, pitch), the melodic essentials of a note.

extract log msgs

extract midi msgs

interesting_midi :: [Midi.WriteMessage] -> [Midi.WriteMessage] Source #

Filter out boring msgs that I don't want tests to rely on.

ui state

call

scale

mkevents

type EventSpec = (RealTime.RealTime, RealTime.RealTime, String, Controls, ScoreTypes.Instrument) Source #

(start, dur, pitch12, controls, inst)

create misc

simple_midi_config :: Patch.Config Source #

A simple config for testing. It's only suitable for tests because normally a Config will have its Patch.config_settings initialized from the Patch.