Wiki: Music Example With Errors

# Music Example With Errors

In this example we describe a music player as if we were operating it. This is an intentionally corrupted version of the MusicExample that shows how various errors are reported.

We'll write the remainder of this page as if it were describing stories for the music player. We'll use italics when we want to point out features of the framework. You might as well run the example now before you continue reading.

- http:run.cgi

Browsing Music

The music browser starts up looking at the whole library of songs. We specify the library (an advanced feature) so that we know what we are talking about in this document.

fit.ActionFixture
start | eg.music.Browser |
enter | library | eg/music/Music.txt
check | total songs | 36 expected 37 actual

This is a the file that library reads. It is tab separated text. Try downloading it and looking at it with a spreadsheet. http:Release/Source/eg/music/Music.txt

We can pick songs and see details of our selection as we go.

fit.ActionFixture
enter | select | 1
check | title | Akila
check | artist | Toure Kunda
enter | select | 2
check | title | American Tango
check | artist | Weather Report
check | album | Mysterious Traveller
check | year | 1975 expected 1974 actual
check | time | 3.70
check | track | 2 of 7

ActionFixture interprets the words in the first column. The check action leads to a comparison of expected values from the table with actual values from the music program.

Playing Music

Once we've picked a song, we can play it. We can continue operating the Brower while music is playing.

eg.music.Realtime | time | split
press | play |  | 18:10:54 | 1
check | status | loading | 18:10:55 | 0
pause | 2 |  | 18:10:55 | 2
check | status | playing expected loading actual | 18:10:57 | 0
pause | 2 |  | 18:10:57 | 2
check | status | playing | 18:10:59 | 0
check | time | 3.70 | 18:10:59 | 0
press | pause |  | 18:10:59 | 1
check | status | pause | 18:11:00 | 0
check | remaining | 3.66 expected 3.67 actual | 18:11:00 | 0
pause | 60 |  | 18:11:00 | 60
check | remaining | 3.66 expected 3.67 actual | 18:12:00 | 0
press | play |  | 18:12:00 | 1
check | status | playing | 18:12:01 | 0
pause | 60 |  | 18:12:01 | 60
check | remaining | 2.66 expected 2.67 actual | 18:13:01 | 0
await | play complete |  | 18:13:01 | 160
check | status | ready | 18:15:41 | 0

The RealtimeActionFixture is a Fixture that adds actions having to do with realtime operation of the music player. We start by pressing play and then waiting for the status to show that it is playing. This music takes 2.5 seconds to start playing so it still says loading after our 2 second pause.

Warning: Don't confuse the pause action with the pause button. The pause action appears in column one where it is interpreted by the Simulator as if the user hesitates for a specified number of seconds. The pause button is a button on the music player part of the Browser screen. The press action activates the pause button which causes the currently playing song to stop temporarily.

Searching for Music

There are buttons on the browser to find more songs like the one we have picked.

We can find songs related in different ways. Each new way produces a (possibly) different list of songs. Show all restores the display to the initial conditions.

eg.music.Realtime | time | split
press | show all |  | 18:15:41 | 1
check | selected songs | 37 | 18:15:42 | 0
enter | select | 3 | 18:15:42 | 1
check | artist | James Taylor | 18:15:43 | 0
press | same artist |  | 18:15:43 | 1
check | selected songs | 5 | 18:15:44 | 0

We left out the await actions so we are mashing buttons every second or so, faster than the searches complete. We're still getting the music we wanted because the search routines don't yet do a very good job of simulating being slow.

Yielding the display:

eg.music.Display
title | artist | album | year | time() | track()
Handy Man | James Taylor | JT | 1977 | 3.30 | 7 of 12
Scarlet Woman missing | Weather Report | Mysterious Traveller | 1974 | 5.72 | 6 of 7
Sailing To Philadelphia | James Taylor | October Rose | 2000 expected 2001 actual | 5.47 | 3 of 3
Ananas | James Taylor | Hourglass | 1997 | 5.73 | 5 of 13
Another Gray Morning missing | James Taylor | JT | 1977 | 2.73 | 4 of 12
Another Grey Morning surplus | James Taylor | JT | 1977 | 2.73 | 4 of 12
Copperline surplus | James Taylor | New Moon Shine | 1991 | 4.37 | 1 of 12

The song Scarlet Woman is marked as missing because our search did not return this row. It really is missing, and rightfully so, because it isn't a James Taylor song.

The song Another Gray Morning is marked as missing because there is no song spelt that way in the result set. When left hand columns (the keys) disagree then we don't get a chance to compare the remaining columns.

The song Copperline wasn't expected in the result set so it is marked as surplus. The framework adds all the surplus songs to the table so that they can be seen. The show up with printing in light gray as a reminder that they are not a part of the original document.

This completes the MusicExample.

Now we consider some degenerate cases just to be sure that they work. Suppose we did not uniquely identify rows. We have two songs from JT. What happens when there are surplus (only one expected) ? When there are missing (three expelcted)?

eg.music.Display
album | genre |  |  |  |
October Rose | Pop | error | error | error | error
Hourglass | Pop | error | error | error | error
New Moon Shine | Pop | error | error | error | error
JT | Pop | error | error | error | error
JT surplus | Pop |  |  |  |

eg.music.Display
album | genre |  |  |  |
JT | Pop | error | error | error | error
October Rose | Pop | error | error | error | error
JT | Pop | error | error | error | error
Hourglass | Pop | error | error | error | error
JT missing | Pop |  |  |  |
New Moon Shine | Pop | error | error | error | error

We've run quite a few test. We'll call up one more Fixture that will add a summary to the end of our document.

fit.Summary
counts | 51 right, 13 wrong, 4 ignores, 0 exceptions
input file | input/MusicExampleWithErrors.html
input update | Sun Apr 30 03:58:36 2006
output file | output/MusicExampleWithErrors.html
run date | Wed May 3 18:10:54 2006
run elapsed time | 0 wallclock secs ( 0.07 usr + 0.01 sys = 0.08 CPU)

This is our most complete standard example. You can run it against more than one fit implementation by choosing any one of these specialized RunScript.

- http:files/LispPlatform/runScheme.cgi
- http:files/LispPlatform/runLisp.cgi

(Caution: these scripts can't login. Run them from the public wiki pages.)

Last edited April 21, 2003