Skip to content

Commit efbe652

Browse files
authored
Add test generators for gigasecond grade-school grains hamming hello-world high-scores house (#249)
[no important files changed]
1 parent f61ad6a commit efbe652

17 files changed

Lines changed: 215 additions & 52 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["input"]["moment"]] | tocsv }},""
3+
{% endfor %}

exercises/practice/gigasecond/data.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
"1959-07-19",""
44
"2015-01-24T22:00:00",""
55
"2015-01-24T23:59:59",""
6-
"2015-01-24T23:59:59",""
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
DROP TABLE IF EXISTS tests;
2+
3+
CREATE TABLE IF NOT EXISTS tests (
4+
-- uuid and description are taken from the test.toml file
5+
uuid TEXT PRIMARY KEY,
6+
description TEXT NOT NULL,
7+
-- The following section is needed by the online test-runner
8+
status TEXT DEFAULT 'fail',
9+
message TEXT,
10+
output TEXT,
11+
test_code TEXT,
12+
task_id INTEGER DEFAULT NULL,
13+
-- Here are columns for the actual tests
14+
property TEXT NOT NULL,
15+
input TEXT NOT NULL, -- json object
16+
expected TEXT NOT NULL -- json array
17+
);
18+
19+
INSERT INTO
20+
tests (uuid, description, property, input, expected)
21+
VALUES
22+
{%- for case in cases %}
23+
(
24+
'{{ case["uuid"] }}',
25+
'{{ case["description"] }}',
26+
'{{ case["property"] }}',
27+
'{{ case["input"] | tojson }}',
28+
{%- if case["property"] == "add" %}
29+
'{{ case["expected"] | tojson | replace('"', '') }}'
30+
{%- else %}
31+
'{{ case["expected"] | tojson }}'
32+
{%- endif %}
33+
{%- if loop.last %}
34+
);
35+
{%- else %}
36+
),
37+
{%- endif %}
38+
{%- endfor %}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["property"], case["input"] | tojson] | tocsv }},""
3+
{% endfor %}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
roster,"{""students"":[]}",
2-
add,"{""students"":[[""Aimee"",2]]}",
3-
roster,"{""students"":[[""Aimee"",2]]}",
4-
add,"{""students"":[[""Blair"",2],[""James"",2],[""Paul"",2]]}",
5-
roster,"{""students"":[[""Blair"",2],[""James"",2],[""Paul"",2]]}",
6-
add,"{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]]}",
7-
roster,"{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]]}",
8-
add,"{""students"":[[""Chelsea"",3],[""Logan"",7]]}",
9-
roster,"{""students"":[[""Chelsea"",3],[""Logan"",7]]}",
10-
add,"{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]]}",
11-
roster,"{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]]}",
12-
roster,"{""students"":[[""Jim"",3],[""Peter"",2],[""Anna"",1]]}",
13-
roster,"{""students"":[[""Peter"",2],[""Zoe"",2],[""Alex"",2]]}",
14-
roster,"{""students"":[[""Peter"",2],[""Anna"",1],[""Barb"",1],[""Zoe"",2],[""Alex"",2],[""Jim"",3],[""Charlie"",1]]}",
15-
grade,"{""students"":[],""desiredGrade"":1}",
16-
grade,"{""students"":[[""Peter"",2],[""Zoe"",2],[""Alex"",2],[""Jim"",3]],""desiredGrade"":1}",
17-
grade,"{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]],""desiredGrade"":2}",
18-
grade,"{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]],""desiredGrade"":2}",
19-
grade,"{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]],""desiredGrade"":3}",
20-
grade,"{""students"":[[""Franklin"",5],[""Bradley"",5],[""Jeff"",1]],""desiredGrade"":5}",
1+
"roster","{""students"":[]}",""
2+
"add","{""students"":[[""Aimee"",2]]}",""
3+
"roster","{""students"":[[""Aimee"",2]]}",""
4+
"add","{""students"":[[""Blair"",2],[""James"",2],[""Paul"",2]]}",""
5+
"roster","{""students"":[[""Blair"",2],[""James"",2],[""Paul"",2]]}",""
6+
"add","{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]]}",""
7+
"roster","{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]]}",""
8+
"add","{""students"":[[""Chelsea"",3],[""Logan"",7]]}",""
9+
"roster","{""students"":[[""Chelsea"",3],[""Logan"",7]]}",""
10+
"add","{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]]}",""
11+
"roster","{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]]}",""
12+
"roster","{""students"":[[""Jim"",3],[""Peter"",2],[""Anna"",1]]}",""
13+
"roster","{""students"":[[""Peter"",2],[""Zoe"",2],[""Alex"",2]]}",""
14+
"roster","{""students"":[[""Peter"",2],[""Anna"",1],[""Barb"",1],[""Zoe"",2],[""Alex"",2],[""Jim"",3],[""Charlie"",1]]}",""
15+
"grade","{""students"":[],""desiredGrade"":1}",""
16+
"grade","{""students"":[[""Peter"",2],[""Zoe"",2],[""Alex"",2],[""Jim"",3]],""desiredGrade"":1}",""
17+
"grade","{""students"":[[""Blair"",2],[""James"",2],[""James"",2],[""Paul"",2]],""desiredGrade"":2}",""
18+
"grade","{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]],""desiredGrade"":2}",""
19+
"grade","{""students"":[[""Blair"",2],[""James"",2],[""James"",3],[""Paul"",3]],""desiredGrade"":3}",""
20+
"grade","{""students"":[[""Franklin"",5],[""Bradley"",5],[""Jeff"",1]],""desiredGrade"":5}",""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["property"] | replace("square", "single-square"), case["input"]["square"] or 0] | tocsv }},0
3+
{% endfor %}

exercises/practice/grains/data.csv

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
single-square,1,0
2-
single-square,2,0
3-
single-square,3,0
4-
single-square,4,0
5-
single-square,16,0
6-
single-square,32,0
7-
single-square,64,0
8-
total,0,0
1+
"single-square",1,0
2+
"single-square",2,0
3+
"single-square",3,0
4+
"single-square",4,0
5+
"single-square",16,0
6+
"single-square",32,0
7+
"single-square",64,0
8+
"total",0,0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
DROP TABLE IF EXISTS tests;
2+
3+
CREATE TABLE IF NOT EXISTS tests (
4+
-- uuid and description are taken from the test.toml file
5+
uuid TEXT PRIMARY KEY,
6+
description TEXT NOT NULL,
7+
-- The following section is needed by the online test-runner
8+
status TEXT DEFAULT 'fail',
9+
message TEXT,
10+
output TEXT,
11+
test_code TEXT,
12+
task_id INTEGER DEFAULT NULL,
13+
-- Here are columns for the actual tests
14+
strand1 TEXT NOT NULL,
15+
strand2 TEXT NOT NULL,
16+
expected_result INTEGER,
17+
expected_error TEXT
18+
);
19+
20+
INSERT INTO
21+
tests (
22+
uuid,
23+
description,
24+
strand1,
25+
strand2,
26+
expected_result,
27+
expected_error
28+
)
29+
VALUES
30+
{%- for case in cases %}
31+
(
32+
'{{ case["uuid"] }}',
33+
'{{ case["description"] }}',
34+
'{{ case["input"]["strand1"] }}',
35+
'{{ case["input"]["strand2"] }}',
36+
{%- if case["expect_error"] %}
37+
null,
38+
'{{ case["expect_error_msg"] }}'
39+
{%- else %}
40+
{{ case["expected"] }},
41+
null
42+
{%- endif %}
43+
{%- if loop.last %}
44+
);
45+
{%- else %}
46+
),
47+
{%- endif %}
48+
{%- endfor %}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["input"]["strand1"], case["input"]["strand2"]] | tocsv }},""
3+
{% endfor %}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"","","",""
2-
"A","A","",""
3-
"G","T","",""
4-
"GGACTGAAATCTG","GGACTGAAATCTG","",""
5-
"GGACGGATTCTG","AGGACGGATTCT","",""
6-
"AATG","AAA","",""
7-
"ATA","AGTG","",""
8-
"","G","",""
9-
"G","","",""
1+
"","",""
2+
"A","A",""
3+
"G","T",""
4+
"GGACTGAAATCTG","GGACTGAAATCTG",""
5+
"GGACGGATTCTG","AGGACGGATTCT",""
6+
"AATG","AAA",""
7+
"ATA","AGTG",""
8+
"","G",""
9+
"G","",""

0 commit comments

Comments
 (0)