sdr 0.7

net.cscott.sdr
Class PMSD

java.lang.Object
  extended by net.cscott.sdr.PMSD

public class PMSD
extends Object

Poor Man's SD is a very simple text-based front-end for debugging and testing.

Author:
C. Scott Ananian
Tests:
Perform basic calls
js> PMSD.scrub(PMSD.runTest("<stdio>",
  >                         "Comment or title lines at the top are ignored",
  >                         "sdr> /setFormation(Formation.SQUARED_SET)",
  >                         "sdr> u turn back",
  >                         "sdr> /program = Program.PLUS; setFormation(Formation.SQUARED_SET)",
  >                         "sdr> do half of a u turn back",
  >                         "sdr> /setFormationWithDancers(FormationList.RH_COLUMN, 0, 1, 2, 3)"))
|sdr> /setFormation(Formation.SQUARED_SET)
||      3Gv  3Bv
|| 
|| 4B>            2G<
|| 
|| 4G>            2B<
|| 
||      1B^  1G^
|sdr> u turn back
||      3G^  3B^
|| 
|| 4B<            2G>
|| 
|| 4G<            2B>
|| 
||      1Bv  1Gv
|sdr> /program = Program.PLUS; setFormation(Formation.SQUARED_SET)
||      3Gv  3Bv
|| 
|| 4B>            2G<
|| 
|| 4G>            2B<
|| 
||      1B^  1G^
|sdr> do half of a u turn back
||      3G>  3B<
|| 
|| 4Bv            2Gv
|| 
|| 4G^            2B^
|| 
||      1B>  1G<
|sdr> /setFormationWithDancers(FormationList.RH_COLUMN, 0, 1, 2, 3)
|| 1B^  1Gv
|| 
|| 2B^  2Gv
|| 
|| 4G^  4Bv
|| 
|| 3G^  3Bv
Special slash commands to access dance state:
js> PMSD.scrub(PMSD.runTest("<stdio>", "sdr> /printFormation"))
|sdr> /printFormation
||      3Gv  3Bv
|| 
|| 4B>            2G<
|| 
|| 4G>            2B<
|| 
||      1B^  1G^
js> PMSD.scrub(PMSD.runTest("<stdio>", "sdr> /ds.currentTime()"))
|sdr> /ds.currentTime()
|0/1
Slash commands can actually be any javascript statement:
js> PMSD.scrub(PMSD.runTest("<stdio>", "sdr> /1+2"))
|sdr> /1+2
|3
js> PMSD.scrub(PMSD.runTest("<stdio>", "sdr> /function f(x) { return x*2 } ; f(4)"))
|sdr> /function f(x) { return x*2 } ; f(4)
|8
We can even nest invocations of PMSD:
js> PMSD.scrub(PMSD.runTest("<outer>",
  >                         "sdr> /const PMSD=net.cscott.sdr.PMSD;",
  >                         "sdr> /PMSD.scrub(PMSD.runTest('<inner>',"+
  >                                                       "'sdr> /\"whee!\"'))"))
|sdr> /const PMSD=net.cscott.sdr.PMSD;
|sdr> /PMSD.scrub(PMSD.runTest('<inner>','sdr> /"whee!"'))
||sdr> /"whee!"
||whee!

Nested Class Summary
static class PMSD.State
          Class holding properties accessible from the PMSD front-end.
 
Method Summary
static void main(String[] args)
          Console front end entry point.
static void repl(org.mozilla.javascript.Context cx, PMSD.State s, net.cscott.sdr.PMSD.ReaderWriter rw)
          Read-evaluate-print loop reusing an existing context and state.
static void repl(net.cscott.sdr.PMSD.ReaderWriter rw, boolean interactive)
          The main read-eval-print loop.
static String runAllTests()
          Run all tests from the net.cscott.sdr.tests.index resource.
static String runTest(PMSD.State s, String sourceName, List<String> lines)
          Run a test transcript, returning the output.
static String runTest(String sourceName, String... transcript)
          Run a test transcript, returning the output.
static String scrub(String input)
          Helper function from doctests to tweak output of runTest(java.lang.String, java.lang.String...).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

runAllTests

public static String runAllTests()
                          throws IOException
Run all tests from the net.cscott.sdr.tests.index resource.

Throws:
IOException

runTest

public static String runTest(String sourceName,
                             String... transcript)
Run a test transcript, returning the output. Helper class for use from JavaScript doctests.


scrub

public static String scrub(String input)
Helper function from doctests to tweak output of runTest(java.lang.String, java.lang.String...).


runTest

public static String runTest(PMSD.State s,
                             String sourceName,
                             List<String> lines)
Run a test transcript, returning the output. The context and state parameters can be null, in which case a new javascript context will be created.


main

public static void main(String[] args)
                 throws IOException
Console front end entry point.

Throws:
IOException

repl

public static void repl(net.cscott.sdr.PMSD.ReaderWriter rw,
                        boolean interactive)
                 throws IOException
The main read-eval-print loop. Creates a new JavaScript score/context.

Throws:
IOException

repl

public static void repl(org.mozilla.javascript.Context cx,
                        PMSD.State s,
                        net.cscott.sdr.PMSD.ReaderWriter rw)
                 throws IOException
Read-evaluate-print loop reusing an existing context and state.

Parameters:
cx - JavaScript context
s - JavaScript scope and state
rw - ReaderWriter object for interaction
Throws:
IOException - if interaction object can't read/write

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian