Edansys

My WordPress Blog

Mar

11

Inform 7 IDE and xUnit testing


Today at work we were discussing unit testing and code coverage tools on .Net. I’ve worked with these tools before on both Java and .Net platforms. But the rehashing today made me draw some analogies to what I’m referring to as the Inform 7 IDE.

Inform is a design system for interactive fiction based on natural language. I started evaluating Inform this previous weekend as a possible platform to introduce my almost nine year old daughter to some form of programming on the computer. Here is what a simple Inform 7 program looks like (this example is from the Wikipedia entry for Inform):

[source:html]

“Hello World” by “I.F. Author”

The story headline is “An Interactive Example”.

The Living Room is a room. “A comfortably furnished living room.” The Kitchen is north of the Living Room. The Front Door is south of the Living Room. The Front Door is a closed locked door.

The insurance salesman is a man in the Living Room. The description is “An insurance salesman in a tacky polyester suit. He seems eager to speak to you.” Understand “man” as the insurance salesman.

A briefcase is carried by the insurance salesman. The description is “A slightly worn, black briefcase.” Understand “case” as the briefcase.

The insurance paperwork is in the briefcase. The description is “Page after page of small legalese.” Understand “papers” or “documents” or “forms” as the paperwork.

Instead of listening to the insurance salesman:
say “The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.”;
now the player carries the insurance paperwork.

[/source]

The Inform IDE keeps a history of the runs of the program. The current and previous runs are graphically depicted in a Skein panel. The skein graphically depicts the various runs through the program as threads that hang from knots with the start knot being the root. Any knot with multiple threads coming out of it represents different runs of the program. The current run is shown in a different color than previous runs.

Inform 7 Skein - click to enlarge

For the current run the Inform 7 IDE also has a Transcript panel that shows the program output and user interaction. This panel shows in two columns. The left column represents the actual output. The right column represents the expected or blessed output. If you ever rerun a thread and the actual output does not match the blessed output, those differences will be highlighted in both the Skein and Transcript panels.
Inform 7 Transcript - click to enlarge

Refer to the Skein tutorial in the Inform Manual for a more complete description of how the Skein and Transcript work.

To complete the analogy to unit testing in Java or .Net, the unit test is represented by the blessed transcript items. The test suite would be the collection of blessed transcript items across all skein threads.

I’m probably over simplifying the analogy and I’m just getting into Inform, so I really do not know the full extent of how the Skein and Transcript can be used. But on the surface, I think this comparison is kind of cool.

I don’t know yet if Inform will be the right thing to introduce my daughter to some form of programming on the computer. It does require less contextual information to get started than say Java, Python, Ruby, or Groovy. I also think she would get some enjoyment out of the interactive fiction part of it.

I’m also interested in Scala, but it suffers like the previous languages mentioned plus I’m not even sure I’m ready for the lambda calculus, existential types and closures. 😉

Tags :