513
by stevenbird
test/test_framework/*, exercises/sample/* |
1 |
<exercise name = "Sum numbers in a file"> |
295
by dilshan_a
Added a filesum problem. |
2 |
<solution>
|
3 |
<![CDATA[
|
|
4 |
print sum(map(int,file(raw_input()).readlines()))
|
|
5 |
]]>
|
|
6 |
</solution>
|
|
7 |
<!-- Alternatively, <solution src="all_input_test_soln.py" /> -->
|
|
8 |
<case name="Normal case"> |
|
9 |
<!-- Specify input -->
|
|
10 |
<stdin>input.txt</stdin> |
|
11 |
<file name='input.txt'><![CDATA[ |
|
12 |
1
|
|
13 |
2
|
|
14 |
3
|
|
15 |
]]>
|
|
16 |
</file>
|
|
17 |
<function desc="Match" default="match"/> |
|
18 |
</case>
|
|
19 |
<case name="Negative numbers"> |
|
20 |
<!-- Specify input -->
|
|
21 |
<stdin>input.txt</stdin> |
|
22 |
<file name='input.txt'><![CDATA[ |
|
23 |
1
|
|
24 |
2
|
|
25 |
-5
|
|
26 |
]]>
|
|
27 |
</file>
|
|
28 |
<function desc="Match" default="match"/> |
|
29 |
</case>
|
|
30 |
<case name="No input"> |
|
31 |
<!-- Specify input -->
|
|
32 |
<stdin>input.txt</stdin> |
|
33 |
<file name='input.txt'><![CDATA[ |
|
34 |
]]>
|
|
35 |
</file>
|
|
36 |
<function desc="Match" default="match"/> |
|
37 |
</case>
|
|
299
by dilshan_a
Test framework now handles exceptions as valid outputs for scripts. |
38 |
<case name="File does not exist"> |
39 |
<!-- Specify input -->
|
|
40 |
<stdin>non_existant_file.txt</stdin> |
|
41 |
<file name='input.txt'><![CDATA[ |
|
42 |
]]>
|
|
43 |
</file>
|
|
44 |
<exception name="IOError"/> |
|
45 |
<function desc="Match exception" default="ignore"> |
|
46 |
<exception/>
|
|
47 |
</function>
|
|
48 |
</case>
|
|
513
by stevenbird
test/test_framework/*, exercises/sample/* |
49 |
</exercise>
|