Revert "Checkpoint making tests independent of version of Python installed."
This reverts commit 531698174e273d1c9f50372eb83c6ab1284deded.
Chris Pressey
2 years ago
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 | #!/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 | 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 | #!/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" |
72 | 72 | Freestyle-format tests can also contain input sections. |
73 | 73 | |
74 | 74 | -> 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)" | |
76 | 76 | |
77 | 77 | -> Tests for functionality "Silly Interpreter" |
78 | 78 |
3 | 3 | Test tests that have test input sections. |
4 | 4 | |
5 | 5 | -> 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)" | |
7 | 7 | |
8 | 8 | -> Tests for functionality "Silly Interpreter" |
9 | 9 |
3 | 3 | |
4 | 4 | Location: test-pass-fail.markdown, line 28 |
5 | 5 | Function: Cat |
6 | Impl : shell command "./cat.sh" | |
6 | Impl : shell command "python cat.py" | |
7 | 7 | Body : meow |
8 | 8 | Expected: output: |
9 | 9 | woof |
16 | 16 | |
17 | 17 | Location: test-pass-fail.markdown, line 31 |
18 | 18 | Function: Cat |
19 | Impl : shell command "./cat.sh" | |
19 | Impl : shell command "python cat.py" | |
20 | 20 | Body : |
21 | 21 | purr |
22 | 22 | prrr |
6 | 6 | incorrect output. |
7 | 7 | |
8 | 8 | -> Functionality "Cat" is implemented by |
9 | -> shell command "./cat.sh" | |
9 | -> shell command "python cat.py" | |
10 | 10 | |
11 | 11 | -> Tests for functionality "Cat" |
12 | 12 |
3 | 3 | Test that tests with input sections can re-use the previous test's test body. |
4 | 4 | |
5 | 5 | -> 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)" | |
7 | 7 | |
8 | 8 | -> Tests for functionality "Silly Interpreter" |
9 | 9 |
7 | 7 | it is not necessary to put any quotes around them in the template string. |
8 | 8 | |
9 | 9 | -> Functionality "Echo Body" is implemented by shell command |
10 | -> "./echo.sh %(test-body-text)" | |
10 | -> "python echo.py %(test-body-text)" | |
11 | 11 | |
12 | 12 | -> Tests for functionality "Echo Body" |
13 | 13 | |
22 | 22 | = don't |
23 | 23 | |
24 | 24 | -> Functionality "Echo Input" is implemented by shell command |
25 | -> "./echo.sh %(test-input-text)" | |
25 | -> "python echo.py %(test-input-text)" | |
26 | 26 | |
27 | 27 | -> Tests for functionality "Echo Input" |
28 | 28 | |
49 | 49 | `%(test-input-file)` and `%(output-file)` as well. |
50 | 50 | |
51 | 51 | -> 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)" | |
53 | 53 | |
54 | 54 | -> Tests for functionality "Cat, from file" |
55 | 55 | |
62 | 62 | = hi |
63 | 63 | |
64 | 64 | -> Functionality "Cat, to file" is implemented by |
65 | -> shell command "./cat.sh -o %(output-file)" | |
65 | -> shell command "python cat.py -o %(output-file)" | |
66 | 66 | |
67 | 67 | -> Tests for functionality "Cat, to file" |
68 | 68 | |
75 | 75 | = hi |
76 | 76 | |
77 | 77 | -> 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)" | |
79 | 79 | |
80 | 80 | -> Tests for functionality "Cat, to and from file" |
81 | 81 | |
88 | 88 | = hi |
89 | 89 | |
90 | 90 | -> 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)" | |
92 | 92 | |
93 | 93 | -> Tests for functionality "Cat input, from file" |
94 | 94 |