Skip to content
Closed
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
15 changes: 15 additions & 0 deletions .github/workflows/check-deprecated-exercises.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Deprecated

on:
pull_request:

jobs:
test-deprecated:
name: Check for deprecated exercises
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
fetch-depth: 0
- name: Test deprecated exercises using test-deprecated-exercises
run: bin/test-deprecated-exercises
49 changes: 49 additions & 0 deletions bin/test-deprecated-exercises
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -eo pipefail

# Determine the base branch of the PR
BASE_BRANCH=${GITHUB_BASE_REF:-main}

# Fetch full history for proper diff
git fetch origin "$BASE_BRANCH"

# Compute merge base
MERGE_BASE=$(git merge-base HEAD origin/"$BASE_BRANCH")

# Get changed files relative to merge base
changed_files=$(git diff --name-only "$MERGE_BASE" HEAD)

# Extract unique exercise directories
changed_exercises=$(echo "$changed_files" | grep -E '^exercises/(practice|concept)/' || true)
changed_exercises=$(echo "$changed_exercises" | cut -d/ -f1-3 | sort -u)

echo "$changed_exercises"

if [ -z "$changed_exercises" ]; then
echo "No exercises changed!"
exit 0
fi

# Deprecated practice exercises
deprecated_exercises=(
"exercises/practice/accumulate"
"exercises/practice/beer-song"
"exercises/practice/binary"
"exercises/practice/diffie-hellman"
"exercises/practice/hexadecimal"
"exercises/practice/minesweeper"
"exercises/practice/octal"
"exercises/practice/strain"
"exercises/practice/trinary"
"exercises/concept/play-your-cards"
)

# Check for deprecated ones
for ex in $changed_exercises; do
if printf '%s\n' "${deprecated_exercises[@]}" | grep -qx "$ex"; then
echo "❌ Deprecated exercise changed: $ex"
exit 1
fi
done

echo "✅ No deprecated exercises changed!"
2 changes: 1 addition & 1 deletion exercises/practice/anagram/src/test/java/AnagramTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void testNoMatches() {

assertThat(
detector.match(
Arrays.asList("hello", "world", "zombies", "pants")))
Arrays.asList("helo", "world", "zombies", "pants")))
.isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;


import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class PrimeCalculatorTest {

private PrimeCalculator primeCalculator = new PrimeCalculator();

@Test
@DisplayName("first prime")
public void testFirstPrime() {
assertThat(primeCalculator.nth(1)).isEqualTo(2);
}

@Disabled("Remove to run test")
@Test
@DisplayName("second prime")
public void testSecondPrime() {
assertThat(primeCalculator.nth(2)).isEqualTo(3);
}

@Disabled("Remove to run test")
@Test
@DisplayName("sixth prime")
public void testSixthPrime() {
assertThat(primeCalculator.nth(6)).isEqualTo(13);
}

@Disabled("Remove to run test")
@Test
@DisplayName("big prime")
public void testBigPrime() {
assertThat(primeCalculator.nth(10001)).isEqualTo(104743);
}

@Disabled("Remove to run test")
@Test
@DisplayName("there is no zeroth prime")
public void testUndefinedPrime() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> primeCalculator.nth(0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Map;
Expand All @@ -9,6 +10,7 @@
public class NucleotideCounterTest {

@Test
@DisplayName("empty strand")
public void testEmptyDnaStringHasNoNucleotides() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("");

Expand All @@ -19,6 +21,7 @@ public void testEmptyDnaStringHasNoNucleotides() {

@Disabled("Remove to run test")
@Test
@DisplayName("can count one nucleotide in single-character input")
public void testDnaStringHasOneNucleotide() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("G");

Expand All @@ -29,6 +32,7 @@ public void testDnaStringHasOneNucleotide() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with repeated nucleotide")
public void testRepetitiveSequenceWithOnlyGuanine() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGGG");

Expand All @@ -39,6 +43,7 @@ public void testRepetitiveSequenceWithOnlyGuanine() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with multiple nucleotides")
public void testDnaStringHasMultipleNucleotide() {
NucleotideCounter nucleotideCounter
= new NucleotideCounter("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC");
Expand All @@ -50,6 +55,7 @@ public void testDnaStringHasMultipleNucleotide() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with invalid nucleotides")
public void testDnaStringHasInvalidNucleotides() {
assertThatThrownBy(() -> new NucleotideCounter("AGXXACT"))
.isInstanceOf(IllegalArgumentException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class OpticalCharacterReaderTest {

@Test
@DisplayName("Recognizes 0")
public void testReaderRecognizesSingle0() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -23,6 +25,7 @@ public void testReaderRecognizesSingle0() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 1")
public void testReaderRecognizesSingle1() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -36,6 +39,7 @@ public void testReaderRecognizesSingle1() {

@Disabled("Remove to run test")
@Test
@DisplayName("Unreadable but correctly sized inputs return ?")
public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -49,6 +53,7 @@ public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() {

@Disabled("Remove to run test")
@Test
@DisplayName("Input with a number of lines that is not a multiple of four raises an error")
public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() {

assertThatExceptionOfType(IllegalArgumentException.class)
Expand All @@ -63,6 +68,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() {

@Disabled("Remove to run test")
@Test
@DisplayName("Input with a number of columns that is not a multiple of three raises an error")
public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3() {


Expand All @@ -79,6 +85,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3()

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 110101100")
public void testReaderRecognizesBinarySequence110101100() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ _ ",
Expand All @@ -92,6 +99,7 @@ public void testReaderRecognizesBinarySequence110101100() {

@Disabled("Remove to run test")
@Test
@DisplayName("Garbled numbers in a string are replaced with ?")
public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ ",
Expand All @@ -106,6 +114,7 @@ public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence()

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 2")
public void testReaderRecognizesSingle2() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -119,6 +128,7 @@ public void testReaderRecognizesSingle2() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 3")
public void testReaderRecognizesSingle3() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -132,6 +142,7 @@ public void testReaderRecognizesSingle3() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 4")
public void testReaderRecognizesSingle4() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -145,6 +156,7 @@ public void testReaderRecognizesSingle4() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 5")
public void testReaderRecognizesSingle5() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -158,6 +170,7 @@ public void testReaderRecognizesSingle5() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 6")
public void testReaderRecognizesSingle6() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -171,6 +184,7 @@ public void testReaderRecognizesSingle6() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 7")
public void testReaderRecognizesSingle7() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -184,6 +198,7 @@ public void testReaderRecognizesSingle7() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 8")
public void testReaderRecognizesSingle8() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -197,6 +212,7 @@ public void testReaderRecognizesSingle8() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 9")
public void testReaderRecognizesSingle9() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -210,6 +226,7 @@ public void testReaderRecognizesSingle9() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes string of decimal numbers")
public void testReaderRecognizesSequence1234567890() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ _ _ _ _ _ ",
Expand All @@ -223,6 +240,7 @@ public void testReaderRecognizesSequence1234567890() {

@Disabled("Remove to run test")
@Test
@DisplayName("Numbers separated by empty lines are recognized. Lines are joined by commas.")
public void testReaderRecognizesAndCorrectlyFormatsMultiRowInput() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ ",
Expand Down
Loading