git @ Cat's Eye Technologies Falderal / a5b66db
Revert "Checkpoint making tests independent of version of Python installed." This reverts commit 531698174e273d1c9f50372eb83c6ab1284deded. Chris Pressey 2 years ago
12 changed file(s) with 49 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
0 import sys
1
2 input = sys.stdin
3 output = sys.stdout
4
5 if len(sys.argv) > 1 and sys.argv[1] == '-f':
6 input = open(sys.argv[2], 'r')
7 sys.argv = sys.argv[2:]
8
9 if len(sys.argv) > 1 and sys.argv[1] == '-o':
10 output = open(sys.argv[2], 'w')
11 sys.argv = sys.argv[2:]
12
13 output.write(input.read())
+0
-9
tests/cat.sh less more
0 #!/bin/sh
1
2 if [ "$1" == "-f"]; then
3 cat <"$2"
4 elif [ "$1" == "-o"]; then
5 cat >"$2"
6 else
7 cat
8 fi
0 import sys
1
2 if sys.argv[1] == '-n':
3 sys.stdout.write(sys.argv[2])
4 else:
5 sys.stdout.write(sys.argv[1] + '\n')
+0
-3
tests/echo.sh less more
0 #!/bin/sh
1
2 printf %s\\n $*
0 import sys
1
2 try:
3 input = raw_input
4 except:
5 pass
6
7 program = open(sys.argv[1]).read().split('\n')
8
9 vars = {}
10 for line in program:
11 if line.startswith('print '):
12 var = line[6]
13 print(vars.get(var, ''))
14 if line.startswith('read '):
15 var = line[5]
16 vars[var] = input('')
+0
-13
tests/silly-interpreter.sh less more
0 #!/bin/sh
1
2 while IFS= read -r line; do
3 if [ "$line" = "print x" ]; then
4 printf %s\\n "$X"
5 elif [ "$line" = "print y" ]; then
6 printf %s\\n "$Y"
7 elif [ "$line" = "read x" ]; then
8 X=`read -r line`
9 elif [ "$line" = "read y" ]; then
10 Y=`read -r line`
11 fi
12 done < "$1"
7272 Freestyle-format tests can also contain input sections.
7373
7474 -> Functionality "Silly Interpreter" is implemented by
75 -> shell command "./silly-interpreter.sh %(test-body-file)"
75 -> shell command "python silly-interpreter.py %(test-body-file)"
7676
7777 -> Tests for functionality "Silly Interpreter"
7878
33 Test tests that have test input sections.
44
55 -> Functionality "Silly Interpreter" is implemented by
6 -> shell command "./silly-interpreter.sh %(test-body-file)"
6 -> shell command "python silly-interpreter.py %(test-body-file)"
77
88 -> Tests for functionality "Silly Interpreter"
99
33
44 Location: test-pass-fail.markdown, line 28
55 Function: Cat
6 Impl : shell command "./cat.sh"
6 Impl : shell command "python cat.py"
77 Body : meow
88 Expected: output:
99 woof
1616
1717 Location: test-pass-fail.markdown, line 31
1818 Function: Cat
19 Impl : shell command "./cat.sh"
19 Impl : shell command "python cat.py"
2020 Body :
2121 purr
2222 prrr
66 incorrect output.
77
88 -> Functionality "Cat" is implemented by
9 -> shell command "./cat.sh"
9 -> shell command "python cat.py"
1010
1111 -> Tests for functionality "Cat"
1212
33 Test that tests with input sections can re-use the previous test's test body.
44
55 -> Functionality "Silly Interpreter" is implemented by
6 -> shell command "./silly-interpreter.sh %(test-body-file)"
6 -> shell command "python silly-interpreter.py %(test-body-file)"
77
88 -> Tests for functionality "Silly Interpreter"
99
77 it is not necessary to put any quotes around them in the template string.
88
99 -> Functionality "Echo Body" is implemented by shell command
10 -> "./echo.sh %(test-body-text)"
10 -> "python echo.py %(test-body-text)"
1111
1212 -> Tests for functionality "Echo Body"
1313
2222 = don't
2323
2424 -> Functionality "Echo Input" is implemented by shell command
25 -> "./echo.sh %(test-input-text)"
25 -> "python echo.py %(test-input-text)"
2626
2727 -> Tests for functionality "Echo Input"
2828
4949 `%(test-input-file)` and `%(output-file)` as well.
5050
5151 -> Functionality "Cat, from file" is implemented by
52 -> shell command "./cat.sh -f %(test-body-file)"
52 -> shell command "python cat.py -f %(test-body-file)"
5353
5454 -> Tests for functionality "Cat, from file"
5555
6262 = hi
6363
6464 -> Functionality "Cat, to file" is implemented by
65 -> shell command "./cat.sh -o %(output-file)"
65 -> shell command "python cat.py -o %(output-file)"
6666
6767 -> Tests for functionality "Cat, to file"
6868
7575 = hi
7676
7777 -> Functionality "Cat, to and from file" is implemented by
78 -> shell command "./cat.sh -f %(test-body-file) -o %(output-file)"
78 -> shell command "python cat.py -f %(test-body-file) -o %(output-file)"
7979
8080 -> Tests for functionality "Cat, to and from file"
8181
8888 = hi
8989
9090 -> Functionality "Cat input, from file" is implemented by
91 -> shell command "./cat.sh -f %(test-input-file)"
91 -> shell command "python cat.py -f %(test-input-file)"
9292
9393 -> Tests for functionality "Cat input, from file"
9494