diff --git a/exercises/practice/tournament/.meta/template.create_test_table.j2 b/exercises/practice/tournament/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..4c0db756 --- /dev/null +++ b/exercises/practice/tournament/.meta/template.create_test_table.j2 @@ -0,0 +1,40 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + input TEXT NOT NULL, + expected TEXT NOT NULL +); + +INSERT INTO + tests (uuid, description, input, expected) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + '{{ case["input"]["rows"] | join("\n") }}', + '{{ case["expected"] | join("\n") }}' +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} + +UPDATE tests +SET + input = REPLACE(input, '\n', CHAR(10)); + +UPDATE tests +SET + expected = REPLACE(expected, '\n', CHAR(10)); diff --git a/exercises/practice/tournament/.meta/template.data.j2 b/exercises/practice/tournament/.meta/template.data.j2 new file mode 100644 index 00000000..64d723d2 --- /dev/null +++ b/exercises/practice/tournament/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +"{{ case["input"]["rows"] | join("\\n") }}","" +{% endfor %} diff --git a/exercises/practice/tournament/create_test_table.sql b/exercises/practice/tournament/create_test_table.sql index 5ad33adc..fe000d58 100644 --- a/exercises/practice/tournament/create_test_table.sql +++ b/exercises/practice/tournament/create_test_table.sql @@ -28,67 +28,117 @@ VALUES '1b4a8aef-0734-4007-80a2-0626178c88f4', 'a win is three points, a loss is zero points', 'Allegoric Alaskans;Blithering Badgers;win', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 1 | 0 | 0 | 3\nBlithering Badgers | 1 | 0 | 0 | 1 | 0' + 'Team | MP | W | D | L | P +Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 +Blithering Badgers | 1 | 0 | 0 | 1 | 0' ), ( '5f45ac09-4efe-46e7-8ddb-75ad85f86e05', 'a win can also be expressed as a loss', 'Blithering Badgers;Allegoric Alaskans;loss', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 1 | 0 | 0 | 3\nBlithering Badgers | 1 | 0 | 0 | 1 | 0' + 'Team | MP | W | D | L | P +Allegoric Alaskans | 1 | 1 | 0 | 0 | 3 +Blithering Badgers | 1 | 0 | 0 | 1 | 0' ), ( 'fd297368-efa0-442d-9f37-dd3f9a437239', 'a different team can win', 'Blithering Badgers;Allegoric Alaskans;win', - 'Team | MP | W | D | L | P\nBlithering Badgers | 1 | 1 | 0 | 0 | 3\nAllegoric Alaskans | 1 | 0 | 0 | 1 | 0' + 'Team | MP | W | D | L | P +Blithering Badgers | 1 | 1 | 0 | 0 | 3 +Allegoric Alaskans | 1 | 0 | 0 | 1 | 0' ), ( '26c016f9-e753-4a93-94e9-842f7b4d70fc', 'a draw is one point each', 'Allegoric Alaskans;Blithering Badgers;draw', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 0 | 1 | 0 | 1\nBlithering Badgers | 1 | 0 | 1 | 0 | 1' + 'Team | MP | W | D | L | P +Allegoric Alaskans | 1 | 0 | 1 | 0 | 1 +Blithering Badgers | 1 | 0 | 1 | 0 | 1' ), ( '731204f6-4f34-4928-97eb-1c307ba83e62', 'There can be more than one match', - 'Allegoric Alaskans;Blithering Badgers;win\nAllegoric Alaskans;Blithering Badgers;win', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 2 | 0 | 0 | 6\nBlithering Badgers | 2 | 0 | 0 | 2 | 0' + 'Allegoric Alaskans;Blithering Badgers;win +Allegoric Alaskans;Blithering Badgers;win', + 'Team | MP | W | D | L | P +Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 +Blithering Badgers | 2 | 0 | 0 | 2 | 0' ), ( '49dc2463-42af-4ea6-95dc-f06cc5776adf', 'There can be more than one winner', - 'Allegoric Alaskans;Blithering Badgers;loss\nAllegoric Alaskans;Blithering Badgers;win', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 1 | 0 | 1 | 3\nBlithering Badgers | 2 | 1 | 0 | 1 | 3' + 'Allegoric Alaskans;Blithering Badgers;loss +Allegoric Alaskans;Blithering Badgers;win', + 'Team | MP | W | D | L | P +Allegoric Alaskans | 2 | 1 | 0 | 1 | 3 +Blithering Badgers | 2 | 1 | 0 | 1 | 3' ), ( '6d930f33-435c-4e6f-9e2d-63fa85ce7dc7', 'There can be more than two teams', - 'Allegoric Alaskans;Blithering Badgers;win\nBlithering Badgers;Courageous Californians;win\nCourageous Californians;Allegoric Alaskans;loss', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 2 | 0 | 0 | 6\nBlithering Badgers | 2 | 1 | 0 | 1 | 3\nCourageous Californians | 2 | 0 | 0 | 2 | 0' + 'Allegoric Alaskans;Blithering Badgers;win +Blithering Badgers;Courageous Californians;win +Courageous Californians;Allegoric Alaskans;loss', + 'Team | MP | W | D | L | P +Allegoric Alaskans | 2 | 2 | 0 | 0 | 6 +Blithering Badgers | 2 | 1 | 0 | 1 | 3 +Courageous Californians | 2 | 0 | 0 | 2 | 0' ), ( '97022974-0c8a-4a50-8fe7-e36bdd8a5945', 'typical input', - 'Allegoric Alaskans;Blithering Badgers;win\nDevastating Donkeys;Courageous Californians;draw\nDevastating Donkeys;Allegoric Alaskans;win\nCourageous Californians;Blithering Badgers;loss\nBlithering Badgers;Devastating Donkeys;loss\nAllegoric Alaskans;Courageous Californians;win', - 'Team | MP | W | D | L | P\nDevastating Donkeys | 3 | 2 | 1 | 0 | 7\nAllegoric Alaskans | 3 | 2 | 0 | 1 | 6\nBlithering Badgers | 3 | 1 | 0 | 2 | 3\nCourageous Californians | 3 | 0 | 1 | 2 | 1' + 'Allegoric Alaskans;Blithering Badgers;win +Devastating Donkeys;Courageous Californians;draw +Devastating Donkeys;Allegoric Alaskans;win +Courageous Californians;Blithering Badgers;loss +Blithering Badgers;Devastating Donkeys;loss +Allegoric Alaskans;Courageous Californians;win', + 'Team | MP | W | D | L | P +Devastating Donkeys | 3 | 2 | 1 | 0 | 7 +Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 +Blithering Badgers | 3 | 1 | 0 | 2 | 3 +Courageous Californians | 3 | 0 | 1 | 2 | 1' ), ( 'fe562f0d-ac0a-4c62-b9c9-44ee3236392b', 'incomplete competition (not all pairs have played)', - 'Allegoric Alaskans;Blithering Badgers;loss\nDevastating Donkeys;Allegoric Alaskans;loss\nCourageous Californians;Blithering Badgers;draw\nAllegoric Alaskans;Courageous Californians;win', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 3 | 2 | 0 | 1 | 6\nBlithering Badgers | 2 | 1 | 1 | 0 | 4\nCourageous Californians | 2 | 0 | 1 | 1 | 1\nDevastating Donkeys | 1 | 0 | 0 | 1 | 0' + 'Allegoric Alaskans;Blithering Badgers;loss +Devastating Donkeys;Allegoric Alaskans;loss +Courageous Californians;Blithering Badgers;draw +Allegoric Alaskans;Courageous Californians;win', + 'Team | MP | W | D | L | P +Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 +Blithering Badgers | 2 | 1 | 1 | 0 | 4 +Courageous Californians | 2 | 0 | 1 | 1 | 1 +Devastating Donkeys | 1 | 0 | 0 | 1 | 0' ), ( '3aa0386f-150b-4f99-90bb-5195e7b7d3b8', 'ties broken alphabetically', - 'Courageous Californians;Devastating Donkeys;win\nAllegoric Alaskans;Blithering Badgers;win\nDevastating Donkeys;Allegoric Alaskans;loss\nCourageous Californians;Blithering Badgers;win\nBlithering Badgers;Devastating Donkeys;draw\nAllegoric Alaskans;Courageous Californians;draw', - 'Team | MP | W | D | L | P\nAllegoric Alaskans | 3 | 2 | 1 | 0 | 7\nCourageous Californians | 3 | 2 | 1 | 0 | 7\nBlithering Badgers | 3 | 0 | 1 | 2 | 1\nDevastating Donkeys | 3 | 0 | 1 | 2 | 1' + 'Courageous Californians;Devastating Donkeys;win +Allegoric Alaskans;Blithering Badgers;win +Devastating Donkeys;Allegoric Alaskans;loss +Courageous Californians;Blithering Badgers;win +Blithering Badgers;Devastating Donkeys;draw +Allegoric Alaskans;Courageous Californians;draw', + 'Team | MP | W | D | L | P +Allegoric Alaskans | 3 | 2 | 1 | 0 | 7 +Courageous Californians | 3 | 2 | 1 | 0 | 7 +Blithering Badgers | 3 | 0 | 1 | 2 | 1 +Devastating Donkeys | 3 | 0 | 1 | 2 | 1' ), ( 'f9e20931-8a65-442a-81f6-503c0205b17a', 'ensure points sorted numerically', - 'Devastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nBlithering Badgers;Devastating Donkeys;win', - 'Team | MP | W | D | L | P\nDevastating Donkeys | 5 | 4 | 0 | 1 | 12\nBlithering Badgers | 5 | 1 | 0 | 4 | 3' + 'Devastating Donkeys;Blithering Badgers;win +Devastating Donkeys;Blithering Badgers;win +Devastating Donkeys;Blithering Badgers;win +Devastating Donkeys;Blithering Badgers;win +Blithering Badgers;Devastating Donkeys;win', + 'Team | MP | W | D | L | P +Devastating Donkeys | 5 | 4 | 0 | 1 | 12 +Blithering Badgers | 5 | 1 | 0 | 4 | 3' ); UPDATE tests diff --git a/exercises/practice/transpose/.meta/template.create_test_table.j2 b/exercises/practice/transpose/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..fef548f2 --- /dev/null +++ b/exercises/practice/transpose/.meta/template.create_test_table.j2 @@ -0,0 +1,37 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + lines TEXT NOT NULL, + expected TEXT NOT NULL +); + +INSERT INTO + tests (uuid, description, lines, expected) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + '{{ case["input"]["lines"] | join("\n") }}', + '{{ case["expected"] | join("\n") }}' +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} + +UPDATE tests +SET + lines = REPLACE(lines, '\n', CHAR(10)), + expected = REPLACE(expected, '\n', CHAR(10)); diff --git a/exercises/practice/transpose/.meta/template.data.j2 b/exercises/practice/transpose/.meta/template.data.j2 new file mode 100644 index 00000000..82e363ca --- /dev/null +++ b/exercises/practice/transpose/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +"{{ case["input"]["lines"] | join("\\n") }}","" +{% endfor %} diff --git a/exercises/practice/transpose/create_test_table.sql b/exercises/practice/transpose/create_test_table.sql index dd6d17f1..dab0322b 100644 --- a/exercises/practice/transpose/create_test_table.sql +++ b/exercises/practice/transpose/create_test_table.sql @@ -28,67 +28,172 @@ VALUES 'a89ce8a3-c940-4703-a688-3ea39412fbcb', 'two characters in a row', 'A1', - 'A\n1' + 'A +1' ), ( '855bb6ae-4180-457c-abd0-ce489803ce98', 'two characters in a column', - 'A\n1', + 'A +1', 'A1' ), ( '5ceda1c0-f940-441c-a244-0ced197769c8', 'simple', - 'ABC\n123', - 'A1\nB2\nC3' + 'ABC +123', + 'A1 +B2 +C3' ), ( 'a54675dd-ae7d-4a58-a9c4-0c20e99a7c1f', 'single line', 'Single line.', - 'S\ni\nn\ng\nl\ne\n \nl\ni\nn\ne\n.' + 'S +i +n +g +l +e + +l +i +n +e +.' ), ( '0dc2ec0b-549d-4047-aeeb-8029fec8d5c5', 'first line longer than second line', - 'The fourth line.\nThe fifth line.', - 'TT\nhh\nee\n \nff\noi\nuf\nrt\nth\nh \n l\nli\nin\nne\ne.\n.' + 'The fourth line. +The fifth line.', + 'TT +hh +ee + +ff +oi +uf +rt +th +h + l +li +in +ne +e. +.' ), ( '984e2ec3-b3d3-4b53-8bd6-96f5ef404102', 'second line longer than first line', - 'The first line.\nThe second line.', - 'TT\nhh\nee\n \nfs\nie\nrc\nso\ntn\n d\nl \nil\nni\nen\n.e\n .' + 'The first line. +The second line.', + 'TT +hh +ee + +fs +ie +rc +so +tn + d +l +il +ni +en +.e + .' ), ( 'eccd3784-45f0-4a3f-865a-360cb323d314', 'mixed line length', - 'The longest line.\nA long line.\nA longer line.\nA line.', - 'TAAA\nh \nelll\n ooi\nlnnn\nogge\nn e.\nglr\nei \nsnl\ntei\n .n\nl e\ni .\nn\ne\n.' + 'The longest line. +A long line. +A longer line. +A line.', + 'TAAA +h +elll + ooi +lnnn +ogge +n e. +glr +ei +snl +tei + .n +l e +i . +n +e +.' ), ( '85b96b3f-d00c-4f80-8ca2-c8a5c9216c2d', 'square', - 'HEART\nEMBER\nABUSE\nRESIN\nTREND', - 'HEART\nEMBER\nABUSE\nRESIN\nTREND' + 'HEART +EMBER +ABUSE +RESIN +TREND', + 'HEART +EMBER +ABUSE +RESIN +TREND' ), ( 'b9257625-7a53-4748-8863-e08e9d27071d', 'rectangle', - 'FRACTURE\nOUTLINED\nBLOOMING\nSEPTETTE', - 'FOBS\nRULE\nATOP\nCLOT\nTIME\nUNIT\nRENT\nEDGE' + 'FRACTURE +OUTLINED +BLOOMING +SEPTETTE', + 'FOBS +RULE +ATOP +CLOT +TIME +UNIT +RENT +EDGE' ), ( 'b80badc9-057e-4543-bd07-ce1296a1ea2c', 'triangle', - 'T\nEE\nAAA\nSSSS\nEEEEE\nRRRRRR', - 'TEASER\n EASER\n ASER\n SER\n ER\n R' + 'T +EE +AAA +SSSS +EEEEE +RRRRRR', + 'TEASER + EASER + ASER + SER + ER + R' ), ( '76acfd50-5596-4d05-89f1-5116328a7dd9', 'jagged triangle', - '11\n2\n3333\n444\n555555\n66666', - '123456\n1 3456\n 3456\n 3 56\n 56\n 5' + '11 +2 +3333 +444 +555555 +66666', + '123456 +1 3456 + 3456 + 3 56 + 56 + 5' ); UPDATE tests diff --git a/exercises/practice/transpose/data.csv b/exercises/practice/transpose/data.csv index 8cf9ff11..ff4aa183 100644 --- a/exercises/practice/transpose/data.csv +++ b/exercises/practice/transpose/data.csv @@ -1,12 +1,12 @@ -"", -"A1", -"A\n1", -"ABC\n123", -"Single line.", -"The fourth line.\nThe fifth line.", -"The first line.\nThe second line.", -"The longest line.\nA long line.\nA longer line.\nA line.", -"HEART\nEMBER\nABUSE\nRESIN\nTREND", -"FRACTURE\nOUTLINED\nBLOOMING\nSEPTETTE", -"T\nEE\nAAA\nSSSS\nEEEEE\nRRRRRR", -"11\n2\n3333\n444\n555555\n66666", +"","" +"A1","" +"A\n1","" +"ABC\n123","" +"Single line.","" +"The fourth line.\nThe fifth line.","" +"The first line.\nThe second line.","" +"The longest line.\nA long line.\nA longer line.\nA line.","" +"HEART\nEMBER\nABUSE\nRESIN\nTREND","" +"FRACTURE\nOUTLINED\nBLOOMING\nSEPTETTE","" +"T\nEE\nAAA\nSSSS\nEEEEE\nRRRRRR","" +"11\n2\n3333\n444\n555555\n66666","" diff --git a/exercises/practice/triangle/.meta/template.create_test_table.j2 b/exercises/practice/triangle/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..b197f454 --- /dev/null +++ b/exercises/practice/triangle/.meta/template.create_test_table.j2 @@ -0,0 +1,46 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + property TEXT NOT NULL, + side_a REAL NOT NULL, + side_b REAL NOT NULL, + side_c REAL NOT NULL, + expected BOOLEAN NOT NULL +); + +INSERT INTO + tests ( + uuid, + description, + property, + side_a, + side_b, + side_c, + expected + ) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + '{{ case["property"] }}', +{%- for side in case["input"]["sides"] %} + {{ side }}, +{%- endfor %} + {{ case["expected"] | quote }} +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} diff --git a/exercises/practice/triangle/.meta/template.data.j2 b/exercises/practice/triangle/.meta/template.data.j2 new file mode 100644 index 00000000..1e78c59d --- /dev/null +++ b/exercises/practice/triangle/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +{{ ([case["property"]] + case["input"]["sides"]) | tocsv }},"" +{% endfor %} diff --git a/exercises/practice/triangle/create_test_table.sql b/exercises/practice/triangle/create_test_table.sql index a98e9780..a52e8a9b 100644 --- a/exercises/practice/triangle/create_test_table.sql +++ b/exercises/practice/triangle/create_test_table.sql @@ -36,7 +36,7 @@ VALUES 2, 2, 2, - true + True ), ( '33eb6f87-0498-4ccf-9573-7f8c3ce92b7b', @@ -45,7 +45,7 @@ VALUES 2, 3, 2, - false + False ), ( 'c6585b7d-a8c0-4ad8-8a34-e21d36f7ad87', @@ -54,7 +54,7 @@ VALUES 5, 4, 6, - false + False ), ( '16e8ceb0-eadb-46d1-b892-c50327479251', @@ -63,7 +63,7 @@ VALUES 0, 0, 0, - false + False ), ( '3022f537-b8e5-4cc1-8f12-fd775827a00c', @@ -72,7 +72,7 @@ VALUES 0.5, 0.5, 0.5, - true + True ), ( 'cbc612dc-d75a-4c1c-87fc-e2d5edd70b71', @@ -81,7 +81,7 @@ VALUES 3, 4, 4, - true + True ), ( 'e388ce93-f25e-4daf-b977-4b7ede992217', @@ -90,7 +90,7 @@ VALUES 4, 4, 3, - true + True ), ( 'd2080b79-4523-4c3f-9d42-2da6e81ab30f', @@ -99,7 +99,7 @@ VALUES 4, 3, 4, - true + True ), ( '8d71e185-2bd7-4841-b7e1-71689a5491d8', @@ -108,7 +108,7 @@ VALUES 4, 4, 4, - true + True ), ( '840ed5f8-366f-43c5-ac69-8f05e6f10bbb', @@ -117,7 +117,7 @@ VALUES 2, 3, 4, - false + False ), ( '2eba0cfb-6c65-4c40-8146-30b608905eae', @@ -126,7 +126,7 @@ VALUES 1, 1, 3, - false + False ), ( '278469cb-ac6b-41f0-81d4-66d9b828f8ac', @@ -135,7 +135,7 @@ VALUES 1, 3, 1, - false + False ), ( '90efb0c7-72bb-4514-b320-3a3892e278ff', @@ -144,7 +144,7 @@ VALUES 3, 1, 1, - false + False ), ( 'adb4ee20-532f-43dc-8d31-e9271b7ef2bc', @@ -153,7 +153,7 @@ VALUES 0.5, 0.4, 0.5, - true + True ), ( 'e8b5f09c-ec2e-47c1-abec-f35095733afb', @@ -162,7 +162,7 @@ VALUES 5, 4, 6, - true + True ), ( '2510001f-b44d-4d18-9872-2303e7977dc1', @@ -171,7 +171,7 @@ VALUES 4, 4, 4, - false + False ), ( 'c6e15a92-90d9-4fb3-90a2-eef64f8d3e1e', @@ -180,7 +180,7 @@ VALUES 4, 4, 3, - false + False ), ( '3da23a91-a166-419a-9abf-baf4868fd985', @@ -189,7 +189,7 @@ VALUES 3, 4, 3, - false + False ), ( 'b6a75d98-1fef-4c42-8e9a-9db854ba0a4d', @@ -198,7 +198,7 @@ VALUES 4, 3, 3, - false + False ), ( '70ad5154-0033-48b7-af2c-b8d739cd9fdc', @@ -207,7 +207,7 @@ VALUES 7, 3, 2, - false + False ), ( '26d9d59d-f8f1-40d3-ad58-ae4d54123d7d', @@ -216,5 +216,5 @@ VALUES 0.5, 0.4, 0.6, - true + True ); diff --git a/exercises/practice/twelve-days/.meta/template.create_test_table.j2 b/exercises/practice/twelve-days/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..ffed29e9 --- /dev/null +++ b/exercises/practice/twelve-days/.meta/template.create_test_table.j2 @@ -0,0 +1,44 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + start_verse INTEGER NOT NULL, + end_verse INTEGER NOT NULL, + expected TEXT NOT NULL +); + +INSERT INTO + tests ( + uuid, + description, + start_verse, + end_verse, + expected + ) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + {{ case["input"]["startVerse"] }}, + {{ case["input"]["endVerse"] }}, + '{{ case["expected"] | join("\n") }}' +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} + +UPDATE tests +SET + expected = REPLACE(expected, '\n', CHAR(10)); diff --git a/exercises/practice/twelve-days/.meta/template.data.j2 b/exercises/practice/twelve-days/.meta/template.data.j2 new file mode 100644 index 00000000..283674a3 --- /dev/null +++ b/exercises/practice/twelve-days/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +{{ [case["input"]["startVerse"], case["input"]["endVerse"]] | tocsv }},"" +{% endfor %} diff --git a/exercises/practice/twelve-days/create_test_table.sql b/exercises/practice/twelve-days/create_test_table.sql index 9f572253..e79c4b41 100644 --- a/exercises/practice/twelve-days/create_test_table.sql +++ b/exercises/practice/twelve-days/create_test_table.sql @@ -114,21 +114,36 @@ VALUES 'recites first three verses of the song', 1, 3, - 'On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\nOn the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.\nOn the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' + 'On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree. +On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree. +On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' ), ( 'c095af0d-3137-4653-ad32-bfb899eda24c', 'recites three verses from the middle of the song', 4, 6, - 'On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' + 'On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' ), ( '20921bc9-cc52-4627-80b3-198cbbfcf9b7', 'recites the whole song', 1, 12, - 'On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\nOn the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.\nOn the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\nOn the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' + 'On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree. +On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree. +On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree. +On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.' ); UPDATE tests diff --git a/exercises/practice/twelve-days/data.csv b/exercises/practice/twelve-days/data.csv index 906b86a2..206456f1 100644 --- a/exercises/practice/twelve-days/data.csv +++ b/exercises/practice/twelve-days/data.csv @@ -1,15 +1,15 @@ -1,1, -2,2, -3,3, -4,4, -5,5, -6,6, -7,7, -8,8, -9,9, -10,10, -11,11, -12,12, -1,3, -4,6, -1,12, +1,1,"" +2,2,"" +3,3,"" +4,4,"" +5,5,"" +6,6,"" +7,7,"" +8,8,"" +9,9,"" +10,10,"" +11,11,"" +12,12,"" +1,3,"" +4,6,"" +1,12,"" diff --git a/exercises/practice/two-fer/.meta/template.data.j2 b/exercises/practice/two-fer/.meta/template.data.j2 new file mode 100644 index 00000000..0edf76f2 --- /dev/null +++ b/exercises/practice/two-fer/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +"{{ case["input"]["name"] or "" }}","" +{% endfor %} diff --git a/exercises/practice/word-count/.meta/template.create_test_table.j2 b/exercises/practice/word-count/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..4228df6b --- /dev/null +++ b/exercises/practice/word-count/.meta/template.create_test_table.j2 @@ -0,0 +1,36 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + sentence TEXT NOT NULL, + expected TEXT NOT NULL -- json object +); + +INSERT INTO + tests (uuid, description, sentence, expected) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + {{ case["input"]["sentence"] | quote }}, + '{{ case["expected"] | tojson | replace("'", "''") }}' +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} + +UPDATE tests +SET + sentence = REPLACE(sentence, '\n', CHAR(10)); diff --git a/exercises/practice/word-count/.meta/template.data.j2 b/exercises/practice/word-count/.meta/template.data.j2 new file mode 100644 index 00000000..ac50cd39 --- /dev/null +++ b/exercises/practice/word-count/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +{{ [case["input"]["sentence"]] | tocsv }},"" +{% endfor %} diff --git a/exercises/practice/word-count/create_test_table.sql b/exercises/practice/word-count/create_test_table.sql index 9327f455..d5bf2cd1 100644 --- a/exercises/practice/word-count/create_test_table.sql +++ b/exercises/practice/word-count/create_test_table.sql @@ -45,7 +45,9 @@ VALUES ( '7349f682-9707-47c0-a9af-be56e1e7ff30', 'handles expanded lists', - 'one,\ntwo,\nthree', + 'one, +two, +three', '{"one":1,"two":1,"three":1}' ), ( @@ -93,7 +95,10 @@ VALUES ( '50176e8a-fe8e-4f4c-b6b6-aa9cf8f20360', 'alternating word separators not detected as a word', - ',\n,one,\n ,two \n ''three''', + ', +,one, + ,two + ''three''', '{"one":1,"two":1,"three":1}' ), ( diff --git a/exercises/practice/word-count/data.csv b/exercises/practice/word-count/data.csv index ee1b5e49..f4f65111 100644 --- a/exercises/practice/word-count/data.csv +++ b/exercises/practice/word-count/data.csv @@ -2,14 +2,18 @@ "one of each","" "one fish two fish red fish blue fish","" "one,two,three","" -"one,\ntwo,\nthree","" +"one, +two, +three","" "car: carpet as java: javascript!!&@$%^&","" "testing, 1, 2 testing","" "go Go GO Stop stop","" -"First: don't laugh. Then: don't cry.","" "'First: don't laugh. Then: don't cry. You're getting it.'","" "Joe can't tell between 'large' and large.","" "Joe can't tell between app, apple and a.","" " multiple whitespaces","" -",\n,one,\n ,two \n 'three'","" +", +,one, + ,two + 'three'","" "can, can't, 'can't'","" diff --git a/exercises/practice/wordy/.meta/template.create_test_table.j2 b/exercises/practice/wordy/.meta/template.create_test_table.j2 new file mode 100644 index 00000000..1ca7922c --- /dev/null +++ b/exercises/practice/wordy/.meta/template.create_test_table.j2 @@ -0,0 +1,44 @@ +DROP TABLE IF EXISTS tests; + +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and description are taken from the test.toml file + uuid TEXT PRIMARY KEY, + description TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + question TEXT NOT NULL, + expected_result INTEGER, + expected_error TEXT +); + +INSERT INTO + tests ( + uuid, + description, + question, + expected_result, + expected_error + ) +VALUES +{%- for case in cases %} + ( + '{{ case["uuid"] }}', + '{{ case["description"] }}', + '{{ case["input"]["question"] }}', +{%- if not case["expect_error"] %} + {{ case["expected"] }}, +{%- else %} + NULL, +{%- endif %} + {{ case.get("expect_error_msg") | quote }} +{%- if loop.last %} + ); +{%- else %} + ), +{%- endif %} +{%- endfor %} diff --git a/exercises/practice/wordy/.meta/template.data.j2 b/exercises/practice/wordy/.meta/template.data.j2 new file mode 100644 index 00000000..d49ef3a0 --- /dev/null +++ b/exercises/practice/wordy/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +{{ [case["input"]["question"]] | tocsv }},"" +{% endfor %} diff --git a/exercises/practice/wordy/data.csv b/exercises/practice/wordy/data.csv index f351dc59..fb7d7149 100644 --- a/exercises/practice/wordy/data.csv +++ b/exercises/practice/wordy/data.csv @@ -1,27 +1,27 @@ -"What is 5?",, -"What is 0?",, -"What is -123?",, -"What is 1 plus 1?",, -"What is 0 plus 2?",, -"What is 3 plus 0?",, -"What is 53 plus 2?",, -"What is -1 plus -10?",, -"What is 123 plus 45678?",, -"What is 4 minus -12?",, -"What is -3 multiplied by 25?",, -"What is 33 divided by -3?",, -"What is 1 plus 1 plus 1?",, -"What is 1 plus 5 minus -2?",, -"What is 20 minus 4 minus 13?",, -"What is 17 minus 6 plus 3?",, -"What is 2 multiplied by -2 multiplied by 3?",, -"What is -3 plus 7 multiplied by -2?",, -"What is -12 divided by 2 divided by -3?",, -"What is 52 cubed?",, -"Who is the President of the United States?",, -"What is 1 plus?",, -"What is?",, -"What is 1 plus plus 2?",, -"What is 1 plus 2 1?",, -"What is 1 2 plus?",, -"What is plus 1 2?",, +"What is 5?","" +"What is 0?","" +"What is -123?","" +"What is 1 plus 1?","" +"What is 0 plus 2?","" +"What is 3 plus 0?","" +"What is 53 plus 2?","" +"What is -1 plus -10?","" +"What is 123 plus 45678?","" +"What is 4 minus -12?","" +"What is -3 multiplied by 25?","" +"What is 33 divided by -3?","" +"What is 1 plus 1 plus 1?","" +"What is 1 plus 5 minus -2?","" +"What is 20 minus 4 minus 13?","" +"What is 17 minus 6 plus 3?","" +"What is 2 multiplied by -2 multiplied by 3?","" +"What is -3 plus 7 multiplied by -2?","" +"What is -12 divided by 2 divided by -3?","" +"What is 52 cubed?","" +"Who is the President of the United States?","" +"What is 1 plus?","" +"What is?","" +"What is 1 plus plus 2?","" +"What is 1 plus 2 1?","" +"What is 1 2 plus?","" +"What is plus 1 2?","" diff --git a/exercises/practice/yacht/.meta/template.data.j2 b/exercises/practice/yacht/.meta/template.data.j2 new file mode 100644 index 00000000..e37e5de1 --- /dev/null +++ b/exercises/practice/yacht/.meta/template.data.j2 @@ -0,0 +1,3 @@ +{%- for case in cases -%} +"{{ case["input"]["dice"] | join(", ")}}","{{ case["input"]["category"] }}","" +{% endfor %}