| @@ 83-111 (lines=29) @@ | ||
| 80 | /* |
|
| 81 | * Test add. |
|
| 82 | */ |
|
| 83 | public function testAdd() |
|
| 84 | { |
|
| 85 | parent::testAdd(); |
|
| 86 | ||
| 87 | $this |
|
| 88 | ->given( |
|
| 89 | $a = $this->fromNative($this->randomNativeNumber()), |
|
| 90 | $b = $this->fromNative($this->randomNativeNumber()) |
|
| 91 | ) |
|
| 92 | ->when($c = $a->add($b->toInteger())) |
|
| 93 | ->then |
|
| 94 | ->object($c) |
|
| 95 | ->isInstanceOf(Decimal::class) |
|
| 96 | ; |
|
| 97 | ||
| 98 | $this |
|
| 99 | ->given( |
|
| 100 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
|
| 101 | $number = $this->fromNative($this->randomNativeNumber()) |
|
| 102 | ) |
|
| 103 | ->then |
|
| 104 | ->boolean($positiveInfinite->addInteger($number->toInteger())->equals($positiveInfinite)) |
|
| 105 | ->isTrue() |
|
| 106 | ->boolean($positiveInfinite->addReal($number->toReal())->equals($positiveInfinite)) |
|
| 107 | ->isTrue() |
|
| 108 | ->boolean($positiveInfinite->addDecimal($number->toDecimal())->equals($positiveInfinite)) |
|
| 109 | ->isTrue() |
|
| 110 | ; |
|
| 111 | } |
|
| 112 | ||
| 113 | /* |
|
| 114 | * Test sub. |
|
| @@ 116-144 (lines=29) @@ | ||
| 113 | /* |
|
| 114 | * Test sub. |
|
| 115 | */ |
|
| 116 | public function testSub() |
|
| 117 | { |
|
| 118 | parent::testSub(); |
|
| 119 | ||
| 120 | $this |
|
| 121 | ->given( |
|
| 122 | $a = $this->fromNative($this->randomNativeNumber()), |
|
| 123 | $b = $this->fromNative($this->randomNativeNumber()) |
|
| 124 | ) |
|
| 125 | ->when($c = $a->sub($b->toInteger())) |
|
| 126 | ->then |
|
| 127 | ->object($c) |
|
| 128 | ->isInstanceOf(Decimal::class) |
|
| 129 | ; |
|
| 130 | ||
| 131 | $this |
|
| 132 | ->given( |
|
| 133 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
|
| 134 | $number = $this->fromNative($this->randomNativeNumber()) |
|
| 135 | ) |
|
| 136 | ->then |
|
| 137 | ->boolean($positiveInfinite->subInteger($number->toInteger())->equals($positiveInfinite)) |
|
| 138 | ->isTrue() |
|
| 139 | ->boolean($positiveInfinite->subReal($number->toReal())->equals($positiveInfinite)) |
|
| 140 | ->isTrue() |
|
| 141 | ->boolean($positiveInfinite->subDecimal($number->toDecimal())->equals($positiveInfinite)) |
|
| 142 | ->isTrue() |
|
| 143 | ; |
|
| 144 | } |
|
| 145 | ||
| 146 | /* |
|
| 147 | * Test mult. |
|
| @@ 149-177 (lines=29) @@ | ||
| 146 | /* |
|
| 147 | * Test mult. |
|
| 148 | */ |
|
| 149 | public function testMult() |
|
| 150 | { |
|
| 151 | parent::testMult(); |
|
| 152 | ||
| 153 | $this |
|
| 154 | ->given( |
|
| 155 | $a = $this->fromNative($this->randomNativeNumber()), |
|
| 156 | $b = $this->fromNative($this->randomNativeNumber()) |
|
| 157 | ) |
|
| 158 | ->when($c = $a->mult($b->toInteger())) |
|
| 159 | ->then |
|
| 160 | ->object($c) |
|
| 161 | ->isInstanceOf(Decimal::class) |
|
| 162 | ; |
|
| 163 | ||
| 164 | $this |
|
| 165 | ->given( |
|
| 166 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
|
| 167 | $number = $this->fromNative($this->randomNativeNumber()) |
|
| 168 | ) |
|
| 169 | ->then |
|
| 170 | ->boolean($positiveInfinite->multInteger($number->toInteger())->equals($positiveInfinite)) |
|
| 171 | ->isTrue() |
|
| 172 | ->boolean($positiveInfinite->multReal($number->toReal())->equals($positiveInfinite)) |
|
| 173 | ->isTrue() |
|
| 174 | ->boolean($positiveInfinite->multDecimal($number->toDecimal())->equals($positiveInfinite)) |
|
| 175 | ->isTrue() |
|
| 176 | ; |
|
| 177 | } |
|
| 178 | ||
| 179 | /* |
|
| 180 | * Test div. |
|
| @@ 182-210 (lines=29) @@ | ||
| 179 | /* |
|
| 180 | * Test div. |
|
| 181 | */ |
|
| 182 | public function testDiv() |
|
| 183 | { |
|
| 184 | parent::testDiv(); |
|
| 185 | ||
| 186 | $this |
|
| 187 | ->given( |
|
| 188 | $a = $this->fromNative($this->randomNativeNumber()), |
|
| 189 | $b = $this->fromNative($this->randomNativeNumber()) |
|
| 190 | ) |
|
| 191 | ->when($c = $a->div($b->toInteger())) |
|
| 192 | ->then |
|
| 193 | ->object($c) |
|
| 194 | ->isInstanceOf(Decimal::class) |
|
| 195 | ; |
|
| 196 | ||
| 197 | $this |
|
| 198 | ->given( |
|
| 199 | $positiveInfinite = $this->fromNative($this->positiveInfiniteNativeNumber()), |
|
| 200 | $number = $this->fromNative($this->randomNativeNumber()) |
|
| 201 | ) |
|
| 202 | ->then |
|
| 203 | ->boolean($positiveInfinite->divInteger($number->toInteger())->equals($positiveInfinite)) |
|
| 204 | ->isTrue() |
|
| 205 | ->boolean($positiveInfinite->divReal($number->toReal())->equals($positiveInfinite)) |
|
| 206 | ->isTrue() |
|
| 207 | ->boolean($positiveInfinite->divDecimal($number->toDecimal())->equals($positiveInfinite)) |
|
| 208 | ->isTrue() |
|
| 209 | ; |
|
| 210 | } |
|
| 211 | ||
| 212 | /* |
|
| 213 | * Test pow. |
|