Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.tests
diff options
context:
space:
mode:
authorWalther Neuper <wneuper@localhost.(none)>2010-05-21 06:41:16 (GMT)
committer Walther Neuper <wneuper@localhost.(none)>2010-05-21 06:41:16 (GMT)
commit90287ec24e76fe0aa0fd71928b5b9accb8af43f4 (patch)
treea5f7710b7a29c4ca8eccf218cc3f95b7c52f79f5 /ReckonPrimer.tests
parent44c59d0e7e9f560b057873be7f26145c43bc973c (diff)
added Schoenharts testfile
Diffstat (limited to 'ReckonPrimer.tests')
-rw-r--r--ReckonPrimer.tests/exaddsub/exaddsub-test.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/ReckonPrimer.tests/exaddsub/exaddsub-test.py b/ReckonPrimer.tests/exaddsub/exaddsub-test.py
new file mode 100644
index 0000000..3a929b7
--- /dev/null
+++ b/ReckonPrimer.tests/exaddsub/exaddsub-test.py
@@ -0,0 +1,69 @@
+from functions import *
+import copy
+
+
+def make_line_sub(calc):
+ """from ([['6','5'],'+',['4','3'],'=',['1','0','8']]
+ make [[' ',' ',' ',' ',' ','6','5',' ',' ',' ',' ',' '],
+ [' ',' ',' ',' ','+','4','3',' ',' ',' ',' ',' '],
+ [' ',' ',' ',' ','-','-','-',' ',' ',' ',' ',' '],
+ [' ',' ',' ',' ','-','-','-',' ',' ',' ',' ',' ']]
+ """
+ _width = 14 #_width = 14 is Display.width,
+ _blanksright = 4 #FIXXXME: _blanksright depends on _width when centering
+ _line1 = make_chars(' ', _width - len(calc[0]) - _blanksright) + \
+ calc[0] + \
+ make_chars(' ', _blanksright)
+ _line2 = make_chars(' ', _width - len(calc[2]) - _blanksright-1) +[calc[1]]+\
+ calc[2] + \
+ make_chars(' ', _blanksright)
+ _line3 = make_chars(' ', _width - max_len(calc) - _blanksright) + \
+ make_chars('-', max_len(calc)) + \
+ make_chars(' ', _blanksright)
+ _line4 = make_chars(' ', _width - len(calc[4]) - _blanksright) +\
+ make_chars('_', len(calc[4])) + \
+ make_chars(' ', _blanksright)
+ return [_line1, _line2, _line3, _line4]
+#calc = [['6','5'],'+',['4','3'],'=',['1','0','8']]
+#print('in TESTexaddsub:make_line_sub(calc)=',make_line_sub(calc))
+##[[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '6', '5', ' ', ' ', ' ', ' '],
+## [' ', ' ', ' ', ' ', ' ', ' ', ' ', '+', '4', '3', ' ', ' ', ' ', ' '],
+## [' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', '-', '-', ' ', ' ', ' ', ' '],
+## [' ', ' ', ' ', ' ', ' ', ' ', ' ', '_', '_', '_', ' ', ' ', ' ', ' ']]
+
+
+
+def make_input_sub(calc):
+ """from ([['6','5'],'+',['4','3'],'=',['1','0','8']])
+ make [(3,6,'8','65+43=___','65+43=__8',
+ [' ',' ',' ',' ','-','-','8',' ',' ',' ',' ',' ']),
+ (3,5,'0','65+43=__8','65+43=_08',
+ [' ',' ',' ',' ','-','0','8',' ',' ',' ',' ',' ']),
+ (3,4,'1','65+43=_08','65+43=108',
+ [' ',' ',' ',' ','1','0','8',' ',' ',' ',' ',' '])]
+ TODO _width = 14 is Display.width,
+ TODO _blanksright depends on _width when centering
+ """
+ _width = 14
+ _blanksright = 4
+ _lines = []
+ _sum = calc[4]
+ _lensum = len(_sum)
+ _protoc = flatten(calc[0:-1]) + make_chars('_', len(_sum))
+ for i in range (len(_sum)):
+ print('i=',i)
+ _input = _sum.pop()
+ _protoc2 = copy.deepcopy(_protoc)
+ _protoc2[len(_protoc)-i-1] = _input
+ _line = (3, 10-i, _input,
+ strs2str(flatten(_protoc)), strs2str(flatten(_protoc2)),
+
+ make_chars(' ', _width - _lensum - _blanksright) +
+ _protoc2[-_lensum:] +
+ make_chars(' ', _blanksright))
+ _lines.append(_line)
+ _protoc = copy.deepcopy(_protoc2)
+ return _lines
+
+#calc = [['6','5'],'+',['4','3'],'=',['1','0','8']]
+#print('in TESTexaddsub:make_input_sub(calc)=',make_input_sub(calc))