Added usage of more correct exceptions.

This commit is contained in:
Gleb Minaev 2022-03-21 18:26:09 +03:00
parent 25ec59b985
commit 88e0dcf413
3 changed files with 3 additions and 2 deletions

View File

@ -295,7 +295,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* If polynomial is a constant polynomial represents and returns it as constant.
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
*/
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
public fun P.asConstant(): C = requireNotNull(asConstantOrNull()) { "Can not represent non-constant polynomial as a constant" }
override fun add(left: P, right: P): P = left + right
override fun multiply(left: P, right: P): P = left * right

View File

@ -460,7 +460,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* If polynomial is a constant polynomial represents and returns it as constant.
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
*/
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
public fun P.asConstant(): C = requireNotNull(asConstantOrNull()) { "Can not represent non-constant polynomial as a constant" }
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is

View File

@ -11,6 +11,7 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
class PolynomialUtilTest {
@Test
fun test_substitute_Double() {