diff --git a/exercises/practice/rna-transcription/.meta/example.sql b/exercises/practice/rna-transcription/.meta/example.sql index e7a362d..10b0711 100644 --- a/exercises/practice/rna-transcription/.meta/example.sql +++ b/exercises/practice/rna-transcription/.meta/example.sql @@ -1,14 +1,15 @@ UPDATE "rna-transcription" -SET result = REPLACE( - REPLACE( +SET + result = REPLACE( REPLACE( REPLACE( - REPLACE(dna, 'A', 'U'), - 'T', 'A' + REPLACE(REPLACE(dna, 'A', 'U'), 'T', 'A'), + 'C', + 'Z' ), - 'C', 'Z' + 'G', + 'C' ), - 'G', 'C' - ), - 'Z', 'G' -); + 'Z', + 'G' + ); diff --git a/exercises/practice/rna-transcription/create_fixture.sql b/exercises/practice/rna-transcription/create_fixture.sql index 8b3fc88..147564a 100644 --- a/exercises/practice/rna-transcription/create_fixture.sql +++ b/exercises/practice/rna-transcription/create_fixture.sql @@ -1,8 +1,6 @@ DROP TABLE IF EXISTS "rna-transcription"; -CREATE TABLE "rna-transcription" ( - "dna" TEXT, - "result" TEXT -); + +CREATE TABLE "rna-transcription" ("dna" TEXT, "result" TEXT); .mode csv .import ./data.csv rna-transcription diff --git a/exercises/practice/rna-transcription/rna-transcription_test.sql b/exercises/practice/rna-transcription/rna-transcription_test.sql index cd983ba..099d100 100644 --- a/exercises/practice/rna-transcription/rna-transcription_test.sql +++ b/exercises/practice/rna-transcription/rna-transcription_test.sql @@ -1,21 +1,60 @@ -- Setup test table and read in student solution: .read ./test_setup.sql - -- Test cases: -INSERT INTO tests (name, uuid, dna, expected) - VALUES - ('Empty RNA sequence', 'b4631f82-c98c-4a2f-90b3-c5c2b6c6f661', '', ''), - ('RNA complement of cytosine is guanine', 'a9558a3c-318c-4240-9256-5d5ed47005a6', 'C', 'G'), - ('RNA complement of guanine is cytosine', '6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7', 'G', 'C'), - ('RNA complement of thymine is adenine', '870bd3ec-8487-471d-8d9a-a25046488d3e', 'T', 'A'), - ('RNA complement of adenine is uracil', 'aade8964-02e1-4073-872f-42d3ffd74c5f', 'A', 'U'), - ('RNA complement', '79ed2757-f018-4f47-a1d7-34a559392dbf', 'ACGTGGTCTTAA', 'UGCACCAGAAUU'); +INSERT INTO + tests (name, uuid, dna, expected) +VALUES + ( + 'Empty RNA sequence', + 'b4631f82-c98c-4a2f-90b3-c5c2b6c6f661', + '', + '' + ), + ( + 'RNA complement of cytosine is guanine', + 'a9558a3c-318c-4240-9256-5d5ed47005a6', + 'C', + 'G' + ), + ( + 'RNA complement of guanine is cytosine', + '6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7', + 'G', + 'C' + ), + ( + 'RNA complement of thymine is adenine', + '870bd3ec-8487-471d-8d9a-a25046488d3e', + 'T', + 'A' + ), + ( + 'RNA complement of adenine is uracil', + 'aade8964-02e1-4073-872f-42d3ffd74c5f', + 'A', + 'U' + ), + ( + 'RNA complement', + '79ed2757-f018-4f47-a1d7-34a559392dbf', + 'ACGTGGTCTTAA', + 'UGCACCAGAAUU' + ); -- Comparison of user input and the tests updates the status for each test: UPDATE tests -SET status = 'pass' -FROM (SELECT dna, result FROM "rna-transcription") AS actual -WHERE (actual.dna, actual.result) = (tests.dna, tests.expected); +SET + status = 'pass' +FROM + ( + SELECT + dna, + result + FROM + "rna-transcription" + ) AS actual +WHERE + (actual.dna, actual.result) = (tests.dna, tests.expected); -- Write results and debug info: .read ./test_reporter.sql diff --git a/exercises/practice/rna-transcription/test_reporter.sql b/exercises/practice/rna-transcription/test_reporter.sql index c8f982b..66e3fa2 100644 --- a/exercises/practice/rna-transcription/test_reporter.sql +++ b/exercises/practice/rna-transcription/test_reporter.sql @@ -1,20 +1,39 @@ -- Update message for failed tests to give helpful information: UPDATE tests -SET message = ( - 'Result for "' || tests.dna || '"' - || ' is <' || COALESCE(actual.result, 'NULL') - || '> but should be <' || tests.expected || '>' -) -FROM (SELECT dna, result FROM 'rna-transcription') AS actual -WHERE actual.dna = tests.dna AND tests.status = 'fail'; +SET + message = ( + 'Result for "' || tests.dna || '"' || ' is <' || COALESCE(actual.result, 'NULL') || '> but should be <' || tests.expected || '>' + ) +FROM + ( + SELECT + dna, + result + FROM + 'rna-transcription' + ) AS actual +WHERE + actual.dna = tests.dna + AND tests.status = 'fail'; -- Save results to ./output.json (needed by the online test-runner) .mode json .once './output.json' -SELECT name, status, message, output, test_code, task_id -FROM tests; +SELECT + name, + status, + message, + output, + test_code, + task_id +FROM + tests; -- Display test results in readable form for the student: .mode table -SELECT name, status, message -FROM tests; +SELECT + name, + status, + message +FROM + tests; diff --git a/exercises/practice/rna-transcription/test_setup.sql b/exercises/practice/rna-transcription/test_setup.sql index 445e297..e26b800 100644 --- a/exercises/practice/rna-transcription/test_setup.sql +++ b/exercises/practice/rna-transcription/test_setup.sql @@ -1,25 +1,24 @@ -- Create database: .read ./create_fixture.sql - -- Read user student solution and save any output as markdown in user_output.md: .mode markdown .output user_output.md .read ./rna-transcription.sql .output - -- Create a clean testing environment: DROP TABLE IF EXISTS tests; + CREATE TABLE IF NOT EXISTS tests ( - -- uuid and name (description) are taken from the test.toml file - uuid TEXT PRIMARY KEY, - name 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 - dna TEXT NOT NULL, - expected TEXT NOT NULL + -- uuid and name (description) are taken from the test.toml file + uuid TEXT PRIMARY KEY, + name 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 + dna TEXT NOT NULL, + expected TEXT NOT NULL );