Skip to content

Rewrite test result message #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion exercises/practice/allergies/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.task || ' ' || tests.item || ' ' || tests.score || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.task || ' ' || tests.item || ' ' || tests.score
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT task, item, score, result FROM allergies) AS actual
WHERE (actual.task, actual.item, actual.score) = (tests.task, tests.item, tests.score) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/armstrong-numbers/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.number || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT number, result FROM "armstrong-numbers") AS actual
WHERE actual.number = tests.number AND tests.status = 'fail';

Expand Down
10 changes: 10 additions & 0 deletions exercises/practice/bob/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = (
'Result for "' || tests.input || '"'
|| ' is <' || COALESCE(actual.reply, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT input, reply FROM bob) AS actual
WHERE actual.input = tests.input AND tests.status = 'fail';

-- Save results to ./output.json (needed by the online test-runner)
.mode json
.once './output.json'
Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/collatz-conjecture/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.number || ' is ' || actual.steps || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.steps, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT number, steps FROM collatz) AS actual
WHERE actual.number = tests.number AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/darts/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.x || ', ' || tests.y || ' is ' || actual.score || ', but should be ' || tests.expected
SET message = (
'Result for (' || tests.x || ', ' || tests.y || ')'
|| ' is <' || COALESCE(actual.score, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT x, y, score FROM darts) AS actual
WHERE (actual.x, actual.y) = (tests.x, tests.y) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/difference-of-squares/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.number || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT number, property, result FROM "difference-of-squares") AS actual
WHERE (actual.number, actual.property) = (tests.number, tests.property) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/eliuds-eggs/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.number || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT number, result FROM "eliuds-eggs") AS actual
WHERE actual.number = tests.number AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/etl/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || actual.input || ' is: ' || actual.result || ', but should be: ' || tests.expected
SET message = (
'Result for ' || tests.input
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT input, result FROM etl) AS actual
WHERE actual.input = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/gigasecond/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.moment || '" is "' || actual.result || '", but should be "' || tests.result || '"'
SET message = (
'Result for ' || tests.moment
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.result || '>'
)
FROM (SELECT moment, result FROM gigasecond) AS actual
WHERE actual.moment = tests.moment AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/grains/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.task || ' as ' || tests.square || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.task || ' as ' || tests.square
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT task, square, result FROM grains) AS actual
WHERE (actual.task, actual.square) = (tests.task, tests.square) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/hello-world/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Upadate message for failed tests to give helpful information:
UPDATE tests
SET message = 'Greeting is: ''' || actual.greeting || ''', but should be: ''' || tests.expected ||''''
SET message = (
'Greeting'
|| ' is "' || COALESCE(actual.greeting, 'NULL')
|| '" but should be "' || tests.expected || '"'
)
FROM (SELECT greeting FROM hello_world) AS actual
WHERE tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/high-scores/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.name || '" is "' || actual.result || '", but should be "' || tests.expected || '"'
SET message = (
'Result for "' || tests.name || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT game_id, result FROM results) AS actual
WHERE actual.game_id = tests.uuid AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/isogram/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.input || '" is ' || actual.is_isogram || ', but should be "' || tests.expected || ''
SET message = (
'Result for "' || tests.input || '"'
|| ' is <' || COALESCE(actual.is_isogram, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT phrase, is_isogram FROM isogram) AS actual
WHERE actual.phrase = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/kindergarten-garden/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.diagram || '" and "' || tests.student || '" is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for "' || tests.diagram || '" and "' || tests.student || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT diagram, student, result FROM 'kindergarten-garden') AS actual
WHERE (actual.diagram, actual.student) = (tests.diagram, tests.student) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/leap/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || actual.year || ' is: ' || actual.is_leap || ', but should be: ' || tests.result
SET message = (
'Result for ' || tests.year
|| ' is <' || COALESCE(actual.is_leap, 'NULL')
|| '> but should be <' || tests.result || '>'
)
FROM (SELECT year, is_leap FROM leap) AS actual
WHERE actual.year = tests.year AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/luhn/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.value || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.value
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT value, result FROM luhn) AS actual
WHERE (actual.value) = (tests.value) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/matching-brackets/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.input || '" is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for "' || tests.input || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT input, result FROM 'matching-brackets') AS actual
WHERE actual.input = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/meetup/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.year || '/' || tests.month || ', ' || tests.week || ' ' || tests.dayofweek
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT year, month, week, dayofweek, result FROM meetup) AS actual
WHERE (actual.year, actual.month, actual.week, actual.dayofweek) = (tests.year, tests.month, tests.week, tests.dayofweek) AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/nucleotide-count/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for "' || tests.input || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT strand, result FROM "nucleotide-count") AS actual
WHERE actual.strand = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/pascals-triangle/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || actual.input || ' is: "' || actual.result || '", but should be: "' || tests.expected || '"'
SET message = (
'Result for ' || tests.input
|| ' is:' || char(10) || COALESCE(actual.result, 'NULL')
|| char(10) || 'but should be:' || char(10) || tests.expected
)
FROM (SELECT input, result FROM "pascals-triangle") AS actual
WHERE actual.input = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/raindrops/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || actual.number || ' is "' || actual.sound || '", but should be: "' || tests.result || '"'
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.sound, 'NULL')
|| '> but should be <' || tests.result || '>'
)
FROM (SELECT number, sound FROM raindrops) AS actual
WHERE actual.number = tests.number AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/resistor-color-duo/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.color1 || ' and ' || tests.color2 || ' is "' || actual.result || '", but should be: "' || tests.expected || '"'
SET message = (
'Result for "' || tests.color1 || '" and "' || tests.color2 || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT color1, color2, result FROM "color_code") AS actual
WHERE (actual.color1, actual.color2) = (tests.color1, tests.color2) AND tests.status = 'fail';

Expand Down
14 changes: 9 additions & 5 deletions exercises/practice/resistor-color/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
-- Update message for failed tests to give helpful information:
UPDATE test_color_code
SET message = 'Result for ' || actual.color || ' is "' || actual.result || '", but should be: "' || test_color_code.result || '"'
UPDATE test_color_code as tests
SET message = (
'Result for "' || tests.color || '"'
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.result || '>'
)
FROM (SELECT color, result FROM color_code) AS actual
WHERE actual.color = test_color_code.color AND test_color_code.status = 'fail';
WHERE actual.color = tests.color AND tests.status = 'fail';


.mode json
.once './output.json'
SELECT name, status, message, output, test_code, task_id
FROM "test_color_code";
FROM test_color_code;

-- Display test results in readable form for the student:
.mode table
SELECT name, status, message
FROM "test_color_code";
FROM test_color_code;
6 changes: 5 additions & 1 deletion exercises/practice/rna-transcription/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for "' || tests.dna || '" is "' || actual.result || '", but should be "' || tests.expected || '"'
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';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/roman-numerals/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || actual.number || ' is "' || actual.result || '", but should be: "' || tests.expected || '"'
SET message = (
'Result for ' || tests.number
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT number, result FROM "roman-numerals") AS actual
WHERE actual.number = tests.number AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/two-fer/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
UPDATE tests
SET message = 'Result for ' || tests.input || ' is ' || actual.response || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.input
|| ' is <' || COALESCE(actual.response, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT input, response FROM twofer) AS actual
WHERE actual.input = tests.input AND tests.status = 'fail';

Expand Down
6 changes: 5 additions & 1 deletion exercises/practice/yacht/test_reporter.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- Update message for failed tests to give helpful information:
UPDATE tests
SET message = 'Result for ' || tests.dice_results || ' as ' || tests.category || ' is ' || actual.result || ', but should be ' || tests.expected
SET message = (
'Result for ' || tests.dice_results || ' as ' || tests.category
|| ' is <' || COALESCE(actual.result, 'NULL')
|| '> but should be <' || tests.expected || '>'
)
FROM (SELECT dice_results, category, result FROM yacht) AS actual
WHERE (actual.dice_results, actual.category) = (tests.dice_results, tests.category) AND tests.status = 'fail';

Expand Down