Commits

Anonymous committed e1bf87a

Also run doctests. Make some doctests exist, for that matter.

Comments (0)

Files changed (3)

src/alpaca/analysis.py

 
 
 class BoundingBox(object):
+    """
+    
+    >>> b = BoundingBox(-2, -3, 2, 3)
+    >>> b
+    BoundingBox(-2, -3, 2, 3)
+    >>> b.expand_to_contain(4, 1)
+    >>> b
+    BoundingBox(-2, -3, 4, 3)
+    >>> b.expand_to_contain(0, -4)
+    >>> b
+    BoundingBox(-2, -4, 4, 3)
+    
+    """
     def __init__(self, min_dx, min_dy, max_dx, max_dy):
         self.min_dx = min_dx
         self.min_dy = min_dy

src/alpaca/main.py

 from optparse import OptionParser
 import sys
 
+from alpaca import analysis
 from alpaca.analysis import (
     construct_representation_map,
     get_default_state,
     optparser.add_option("-t", "--test",
                          action="store_true", dest="test", default=False,
                          help="run test cases and exit")
+    optparser.add_option("-v", "--verbose",
+                         action="store_true", dest="verbose", default=False,
+                         help="run verbosely (test cases only for now)")
     optparser.add_option("-y", "--include-yoob-playfield-inline",
                          action="store_true",
                          dest="include_yoob_playfield_inline", default=False,
     (options, args) = optparser.parse_args(argv[1:])
     if options.test:
         import doctest
-        (fails, something) = doctest.testmod()
+        (fails, something) = doctest.testmod(analysis)
         if fails == 0:
             print "All tests passed."
             sys.exit(0)
 # usage: ./test.sh [js]
 # js option will test compiling to Javascript (requires node.js.)
 
+bin/alpaca -t || exit 1
+
 cat >test_config <<EOF
     -> Functionality "Parse ALPACA Description" is implemented by shell command
     -> "./bin/alpaca -p %(test-file) && echo 'ok'"