From 1266931d168211f6d933238ca782ce5793191a7d Mon Sep 17 00:00:00 2001 From: David Schwarz Date: Mon, 16 Jan 2023 00:02:04 +0100 Subject: [PATCH] v1.0.1 - add example in README.md - fix typo NegativeResultError->message - improve tests - cleanup --- .php-cs-fixer.dist.php | 9 --------- README.md | 1 + src/NegativeResultError.php | 2 +- tests/LineTest.php | 4 ++++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7f80028..9e7b7b7 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,14 +1,5 @@ equals($startLine); // FALSE $otherLine->equals(2); // TRUE (string) Line::number(7); // '7' +Line::number(7)->i; // 7 Line::number(-1); // ...\NegativeValueError diff --git a/src/NegativeResultError.php b/src/NegativeResultError.php index c0b540d..d668d56 100644 --- a/src/NegativeResultError.php +++ b/src/NegativeResultError.php @@ -26,6 +26,6 @@ class NegativeResultError extends Error public function __construct(int $a, string $operator, int $b, int $result, ?Throwable $previous = null) { $computation = ''.$a.$operator.$b; - parent::__construct(sprintf('The result "%s of "%s" is less than zero.', $result, $computation), previous: $previous); + parent::__construct(sprintf('The result "%s" of "%s" is less than zero.', $result, $computation), previous: $previous); } } diff --git a/tests/LineTest.php b/tests/LineTest.php index 9eb5423..dfae3da 100644 --- a/tests/LineTest.php +++ b/tests/LineTest.php @@ -64,6 +64,8 @@ public function testAdd(): void { $this->assertSame(7, Line::number(5)->add(2)->i); $this->assertSame(3, Line::number(5)->add(-2)->i); + + $this->assertSame(7, Line::number(5)->add(Line::number(2))->i); } public function testErrorOnNegativeSum(): void @@ -76,6 +78,8 @@ public function testSubtract(): void { $this->assertSame(7, Line::number(9)->subtract(2)->i); $this->assertSame(7, Line::number(5)->subtract(-2)->i); + + $this->assertSame(7, Line::number(9)->subtract(Line::number(2))->i); } public function testErrorOnNegativeDifference(): void