diff --git a/bin/auto-sync.txt b/bin/auto-sync.txt index bf8742fe..72dbe849 100644 --- a/bin/auto-sync.txt +++ b/bin/auto-sync.txt @@ -49,6 +49,7 @@ markdown matching-brackets matrix meetup +nth-prime micro-blog nucleotide-count ocr-numbers diff --git a/exercises/practice/nth-prime/.docs/instructions.md b/exercises/practice/nth-prime/.docs/instructions.md index 30a75216..065e323a 100644 --- a/exercises/practice/nth-prime/.docs/instructions.md +++ b/exercises/practice/nth-prime/.docs/instructions.md @@ -2,8 +2,6 @@ Given a number n, determine what the nth prime is. -By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that -the 6th prime is 13. +By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. -If your language provides methods in the standard library to deal with prime -numbers, pretend they don't exist and implement them yourself. +If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself. diff --git a/exercises/practice/nth-prime/.meta/config.json b/exercises/practice/nth-prime/.meta/config.json index 0b44d248..0ae4fb01 100644 --- a/exercises/practice/nth-prime/.meta/config.json +++ b/exercises/practice/nth-prime/.meta/config.json @@ -7,7 +7,8 @@ "kunicmarko20", "kytrinyx", "petemcfarlane", - "yisraeldov" + "yisraeldov", + "Narkunan" ], "files": { "solution": [ diff --git a/exercises/practice/nth-prime/.meta/example.php b/exercises/practice/nth-prime/.meta/example.php index 17d2c8fc..3d3508e7 100644 --- a/exercises/practice/nth-prime/.meta/example.php +++ b/exercises/practice/nth-prime/.meta/example.php @@ -1,33 +1,11 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); function prime($count) { if ($count < 1) { - return false; + throw new Exception('there is no zeroth prime'); } $primes = []; $i = 2; diff --git a/exercises/practice/nth-prime/NthPrimeTest.php b/exercises/practice/nth-prime/NthPrimeTest.php index c9f1f9f4..b318e325 100644 --- a/exercises/practice/nth-prime/NthPrimeTest.php +++ b/exercises/practice/nth-prime/NthPrimeTest.php @@ -1,29 +1,8 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); +use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; class NthPrimeTest extends TestCase @@ -33,24 +12,40 @@ public static function setUpBeforeClass(): void require_once 'NthPrime.php'; } + /** uuid: 75c65189-8aef-471a-81de-0a90c728160c */ + #[TestDox('first prime')] public function testFirstPrime(): void { $this->assertEquals(2, prime(1)); } + + /** uuid: 2c38804c-295f-4701-b728-56dea34fd1a0 */ + #[TestDox('second prime')] public function testSecondPrime(): void { $this->assertEquals(3, prime(2)); } + + /** uuid: 56692534-781e-4e8c-b1f9-3e82c1640259 */ + #[TestDox('sixth prime')] public function testSixthPrime(): void { $this->assertEquals(13, prime(6)); } + + /** uuid: fce1e979-0edb-412d-93aa-2c744e8f50ff */ + #[TestDox('big prime')] public function testBigPrime(): void { $this->assertEquals(104743, prime(10001)); } + + /** uuid: bd0a9eae-6df7-485b-a144-80e13c7d55b2 */ + #[TestDox('there is no zeroth prime')] public function testZeroPrime(): void { - $this->assertEquals(false, prime(0)); + $this->expectException(Exception::class); + $this->expectExceptionMessage('there is no zeroth prime'); + prime(0); } }