[gnome-calculator] GCalc: Simplify MathConstant interface for new types
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] GCalc: Simplify MathConstant interface for new types
- Date: Thu, 17 Oct 2019 20:04:40 +0000 (UTC)
commit 0e7192bdb44829fa4b445a97a42a32e701fd07de
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 17 14:41:03 2019 -0500
GCalc: Simplify MathConstant interface for new types
Added new constant values types: number and complex, all implemented
by Constant class
gcalc/gcalc-constant.vala | 13 +-
gcalc/gcalc-math-constant-complex.vala | 38 ++++
gcalc/gcalc-math-constant-number.vala | 30 ++++
gcalc/gcalc-math-constant.vala | 27 +--
gcalc/meson.build | 2 +
tests/gcalc-parsing.vala | 12 +-
tests/gcalc-solving-basic.vala | 316 ++++++++++++++++-----------------
7 files changed, 251 insertions(+), 187 deletions(-)
---
diff --git a/gcalc/gcalc-constant.vala b/gcalc/gcalc-constant.vala
index 7a85aa13..f8d2e03e 100644
--- a/gcalc/gcalc-constant.vala
+++ b/gcalc/gcalc-constant.vala
@@ -21,7 +21,11 @@
/**
* An implementation of {@link MathConstant}
*/
-public class GCalc.Constant : Expression, MathConstant {
+public class GCalc.Constant : Expression,
+ MathConstant,
+ MathConstantNumber,
+ MathConstantComplex
+{
private MPC.Complex _complex = MPC.Complex (1000);
internal unowned MPC.Complex get_complex () { return _complex; }
@@ -45,7 +49,7 @@ public class GCalc.Constant : Expression, MathConstant {
_complex.set_double (real, imag);
}
- // MathConstant Interface
+ // MathConstantComplex Interface
internal double real () {
return _complex.get_real_double ();
}
@@ -57,7 +61,12 @@ public class GCalc.Constant : Expression, MathConstant {
r.set_zero ();
_complex.set_mpreal (r);
}
+ // MathConstantNumber Interface
+ internal double @value () {
+ return real ();
+ }
+ // MathConstant Interface
internal MathConstant add (MathConstant c)
requires (c is Constant)
{
diff --git a/gcalc/gcalc-math-constant-complex.vala b/gcalc/gcalc-math-constant-complex.vala
new file mode 100644
index 00000000..7308e186
--- /dev/null
+++ b/gcalc/gcalc-math-constant-complex.vala
@@ -0,0 +1,38 @@
+/* gcalc-math-constant-complex.vala
+ *
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Espinosa <esodan gmail com>
+ */
+/**
+ * A constant as a complex number with real and imaginary parts
+ */
+public interface GCalc.MathConstantComplex : Object, MathExpression, MathConstant {
+ /**
+ * Returns the real part of the complex number
+ */
+ public abstract double real ();
+ /**
+ * Returns the imaginary part of the complex number
+ */
+ public abstract double imag ();
+ /**
+ * Set the complex number to zero
+ */
+ public abstract void zero ();
+}
+
diff --git a/gcalc/gcalc-math-constant-number.vala b/gcalc/gcalc-math-constant-number.vala
new file mode 100644
index 00000000..e66c51e4
--- /dev/null
+++ b/gcalc/gcalc-math-constant-number.vala
@@ -0,0 +1,30 @@
+/* gcalc-math-constant-number.vala
+ *
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Espinosa <esodan gmail com>
+ */
+/**
+ * A constant number value with a double precision number
+ */
+public interface GCalc.MathConstantNumber : Object, MathExpression, MathConstant {
+ /**
+ * Returns the value
+ */
+ public abstract double @value ();
+}
+
diff --git a/gcalc/gcalc-math-constant.vala b/gcalc/gcalc-math-constant.vala
index 76890e54..be141bbf 100644
--- a/gcalc/gcalc-math-constant.vala
+++ b/gcalc/gcalc-math-constant.vala
@@ -20,50 +20,35 @@
*/
/**
* A constant value in a math expression.
- *
- * This constant is a complex number with real and imaginary parts;
- * and multiple-precision.
*/
public interface GCalc.MathConstant : Object, MathExpression {
/**
- * Returns the real part of the complex number
- */
- public abstract double real ();
- /**
- * Returns the imaginary part of the complex number
- */
- public abstract double imag ();
- /**
- * Set the complex number to zero
- */
- public abstract void zero ();
- /**
- * Add this value with another complex number and returns
+ * Add this value with another and returns
* the result
*/
public abstract MathConstant add (MathConstant c);
/**
- * Subtract another complex number from this value and returns
+ * Subtract another from this value and returns
* the result
*/
public abstract MathConstant subtract (MathConstant c);
/**
- * Multipy another complex number with this value and returns
+ * Multipy another with this value and returns
* the result
*/
public abstract MathConstant multiply (MathConstant c);
/**
- * Divide this value as numerator with another complex number as denominator
+ * Divide this value as numerator with another as denominator
* and returns the result
*/
public abstract MathConstant divide (MathConstant c);
/**
- * Changes the direction of this complex value and returns
+ * Changes the direction of the value and returns
* the result
*/
public abstract MathConstant neg ();
/**
- * Pows this value using another complex number and returns
+ * Pows this value using another and returns
* the result
*/
public abstract MathConstant pow (MathConstant c);
diff --git a/gcalc/meson.build b/gcalc/meson.build
index dcfc78b8..e0694127 100644
--- a/gcalc/meson.build
+++ b/gcalc/meson.build
@@ -86,6 +86,8 @@ gcalc_sources = files([
'gcalc-math-assign.vala',
'gcalc-math-binary-operator.vala',
'gcalc-math-constant.vala',
+ 'gcalc-math-constant-complex.vala',
+ 'gcalc-math-constant-number.vala',
'gcalc-math-division.vala',
'gcalc-math-equation.vala',
'gcalc-math-equation-manager.vala',
diff --git a/tests/gcalc-parsing.vala b/tests/gcalc-parsing.vala
index 5cb1c440..d3e80721 100644
--- a/tests/gcalc-parsing.vala
+++ b/tests/gcalc-parsing.vala
@@ -1126,21 +1126,21 @@ class Tests {
var r = eq.solve ();
assert (r.expression != null);
assert (r.expression is MathConstant);
- var cr = r.expression as MathConstant;
+ var cr = r.expression as MathConstantNumber;
assert (cr != null);
- assert (cr.real () == 0.0);
+ assert (cr.@value () == 0.0);
var p = eq.variables.find_named ("param1") as GCalc.MathParameter;
assert (p != null);
p.set_value (10.0);
r = eq.solve ();
assert (r.expression != null);
assert (r.expression is MathConstant);
- cr = r.expression as MathConstant;
- assert (cr != null);
- assert (cr.real () == 10.0);
+ var cxr = r.expression as MathConstantComplex;
+ assert (cxr != null);
+ assert (cxr.real () == 10.0);
var eq2 = eqman.equations.get_item (1) as MathEquation;
assert (eq2 != null);
- var cr2 = r.expression as MathConstant;
+ var cr2 = r.expression as MathConstantComplex;
assert (cr2 != null);
assert (cr2.real () == 10.0);
} catch (GLib.Error error) {
diff --git a/tests/gcalc-solving-basic.vala b/tests/gcalc-solving-basic.vala
index a50f9807..a4fd4f15 100644
--- a/tests/gcalc-solving-basic.vala
+++ b/tests/gcalc-solving-basic.vala
@@ -27,50 +27,50 @@ class Tests {
()=>{
var c1 = new Constant.@double (3.0);
var c2 = new Constant.@double (3.0);
- var c3 = c1.add (c2);
+ var c3 = c1.add (c2) as MathConstantNumber;
assert (c3 != null);
message (c3.to_string ());
- assert (c3.real () == 6.0);
+ assert (c3.@value () == 6.0);
});
Test.add_func ("/gcalc/solve/constant/subtract",
()=>{
var c1 = new Constant.@double (9.0);
var c2 = new Constant.@double (3.0);
- var c3 = c1.subtract (c2);
+ var c3 = c1.subtract (c2) as MathConstantNumber;
assert (c3 != null);
message (c3.to_string ());
- assert (c3.real () == 6.0);
+ assert (c3.@value () == 6.0);
});
Test.add_func ("/gcalc/solve/constant/multiply",
()=>{
var c1 = new Constant.@double (3.0);
var c2 = new Constant.@double (3.0);
- var c3 = c1.multiply (c2);
+ var c3 = c1.multiply (c2) as MathConstantNumber;
assert (c3 != null);
message (c3.to_string ());
- assert (c3.real () == 9.0);
+ assert (c3.@value () == 9.0);
});
Test.add_func ("/gcalc/solve/constant/devide",
()=>{
var c1 = new Constant.@double (9.0);
var c2 = new Constant.@double (3.0);
- var c3 = c1.divide (c2);
+ var c3 = c1.divide (c2) as MathConstantNumber;
assert (c3 != null);
message (c3.to_string ());
- assert (c3.real () == 3.0);
+ assert (c3.@value () == 3.0);
});
Test.add_func ("/gcalc/solve/constant/negation",
()=>{
var c1 = new Constant.@double (9.0);
- var c3 = c1.neg ();
+ var c3 = c1.neg () as MathConstantNumber;
assert (c3 != null);
message (c3.to_string ());
- assert (c3.real () == -9.0);
+ assert (c3.@value () == -9.0);
});
Test.add_func ("/gcalc/solve/constant/complex",
()=>{
var c1 = new Constant.complex (10.0, 15.0);
- var c3 = c1.neg ();
+ var c3 = c1.neg () as MathConstantComplex;
assert (c3 != null);
message (c3.to_string ());
assert (c3.real () == -10.0);
@@ -89,15 +89,15 @@ class Tests {
assert (e != null);
var t = e.expressions.get_item (0) as MathTerm;
assert (t != null);
- var c = t.expressions.get_item (0) as MathConstant;
+ var c = t.expressions.get_item (0) as MathConstantNumber;
assert (c != null);
var res = c.solve ();
assert (res != null);
assert (res.expression != null);
- var rc = res.expression as MathConstant;
+ var rc = res.expression as MathConstantNumber;
assert (rc != null);
message ("MathConstant Result: %s", rc.to_string ());
- assert (rc.real () == 1.0);
+ assert (rc.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -119,10 +119,10 @@ class Tests {
assert (res.expression != null);
message ("Result type: %s", res.expression.get_type ().name ());
assert (!(res is ErrorResult));
- var rc = res.expression as MathConstant;
+ var rc = res.expression as MathConstantNumber;
assert (rc != null);
message ("MathConstant Result: %s", rc.to_string ());
- assert (rc.real () == 1.0);
+ assert (rc.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -144,10 +144,10 @@ class Tests {
assert (res.expression != null);
message ("Result type: %s", res.expression.get_type ().name ());
assert (!(res is ErrorResult));
- var rc = res.expression as MathConstant;
+ var rc = res.expression as MathConstantNumber;
assert (rc != null);
message ("MathConstant Result: %s", rc.to_string ());
- assert (rc.real () == 15.0);
+ assert (rc.@value () == 15.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -169,10 +169,10 @@ class Tests {
assert (res.expression != null);
message ("Result type: %s", res.expression.get_type ().name ());
assert (!(res is ErrorResult));
- var rc = res.expression as MathConstant;
+ var rc = res.expression as MathConstantNumber;
assert (rc != null);
message ("MathConstant Result: %s", rc.to_string ());
- assert (rc.real () == 5.0);
+ assert (rc.@value () == 5.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -193,10 +193,10 @@ class Tests {
var res = t1.add (t2);
assert (res != null);
message (res.get_type ().name ());
- var c = res as MathConstant;
+ var c = res as MathConstantNumber;
assert (c != null);
message (c.to_string ());
- assert (c.real () == 2.0);
+ assert (c.@value () == 2.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -215,10 +215,10 @@ class Tests {
var res = e.evaluate ();
assert (res != null);
message (res.get_type ().name ());
- var c = res as MathConstant;
+ var c = res as MathConstantNumber;
assert (c != null);
message (c.to_string ());
- assert (c.real () == -2.0);
+ assert (c.@value () == -2.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -237,10 +237,10 @@ class Tests {
var res = e.evaluate ();
assert (res != null);
message (res.get_type ().name ());
- var c = res as MathConstant;
+ var c = res as MathConstantNumber;
assert (c != null);
message (c.to_string ());
- assert (c.real () == 7.0);
+ assert (c.@value () == 7.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -260,10 +260,10 @@ class Tests {
assert (t != null);
var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
- var res = g.evaluate () as MathConstant;
+ var res = g.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 1.0);
+ assert (res.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -279,10 +279,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 1.0);
+ assert (res.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -298,10 +298,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 5.0);
+ assert (res.@value () == 5.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -317,10 +317,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 6.0);
+ assert (res.@value () == 6.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -340,10 +340,10 @@ class Tests {
assert (t != null);
var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
- var res = g.evaluate () as MathConstant;
+ var res = g.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 3.0);
+ assert (res.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -363,10 +363,10 @@ class Tests {
assert (t != null);
var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
- var res = g.evaluate () as MathConstant;
+ var res = g.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 14.0);
+ assert (res.@value () == 14.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -382,10 +382,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 5.0);
+ assert (res.@value () == 5.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -401,10 +401,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 25.0);
+ assert (res.@value () == 25.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -420,10 +420,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 26.0);
+ assert (res.@value () == 26.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -439,10 +439,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 25.0);
+ assert (res.@value () == 25.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -458,10 +458,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == -103.0);
+ assert (res.@value () == -103.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -472,10 +472,10 @@ class Tests {
var c1 = new Constant.@double (9.0);
var f = new FunctionSqrt ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -486,10 +486,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionExp ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 1.0);
+ assert (c2.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -500,10 +500,10 @@ class Tests {
var c1 = new Constant.@double (1.0);
var f = new FunctionLog ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -514,10 +514,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionSin ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -528,10 +528,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionCos ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 1.0);
+ assert (c2.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -542,10 +542,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionTan ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -556,10 +556,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionAsin ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -570,10 +570,10 @@ class Tests {
var c1 = new Constant.@double (1.0);
var f = new FunctionAcos ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -584,10 +584,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionAtan ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -598,10 +598,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionSinh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -612,10 +612,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionCosh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 1.0);
+ assert (c2.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -626,10 +626,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionTanh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -640,10 +640,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionAsinh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -654,10 +654,10 @@ class Tests {
var c1 = new Constant.@double (1.0);
var f = new FunctionAcosh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -668,10 +668,10 @@ class Tests {
var c1 = new Constant.@double (0.0);
var f = new FunctionAtanh ();
f.expressions.add (c1);
- var c2 = f.evaluate () as MathConstant;
+ var c2 = f.evaluate () as MathConstantNumber;
assert (c2 != null);
message (c2.to_string ());
- assert (c2.real () == 0.0);
+ assert (c2.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -692,10 +692,10 @@ class Tests {
var f = t.expressions.get_item (0) as MathFunction;
assert (f != null);
assert (f.closed);
- var res = f.evaluate () as MathConstant;
+ var res = f.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 0.0);
+ assert (res.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -711,10 +711,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 0.0);
+ assert (res.@value () == 0.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -730,10 +730,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 3.0);
+ assert (res.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -749,10 +749,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 3.0);
+ assert (res.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -768,10 +768,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 3.0);
+ assert (res.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -787,10 +787,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 1.0);
+ assert (res.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -806,10 +806,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 5.0);
+ assert (res.@value () == 5.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -825,10 +825,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 5.0);
+ assert (res.@value () == 5.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -844,10 +844,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 1.0);
+ assert (res.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -863,10 +863,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 2.0);
+ assert (res.@value () == 2.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -882,10 +882,10 @@ class Tests {
assert (eq != null);
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 3.0);
+ assert (res.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -902,10 +902,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == -7.0);
+ assert (res.@value () == -7.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -922,10 +922,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 1.0);
+ assert (res.@value () == 1.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -942,10 +942,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 23.5);
+ assert (res.@value () == 23.5);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -962,10 +962,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 27.0);
+ assert (res.@value () == 27.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -982,10 +982,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 256.0);
+ assert (res.@value () == 256.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1002,10 +1002,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 256.0);
+ assert (res.@value () == 256.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1022,10 +1022,10 @@ class Tests {
message ("Equation: %s", eq.to_string ());
var e = eq.expressions.get_item (0) as MathPolynomial;
assert (e != null);
- var res = e.evaluate () as MathConstant;
+ var res = e.evaluate () as MathConstantNumber;
assert (res != null);
message ("MathConstant Result: %s", res.to_string ());
- assert (res.real () == 28.0);
+ assert (res.@value () == 28.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1041,17 +1041,17 @@ class Tests {
assert (eq != null);
var a = eq.expressions.get_item (0) as MathAssign;
assert (a != null);
- var res1 = a.evaluate () as MathConstant;
+ var res1 = a.evaluate () as MathConstantNumber;
assert (res1 != null);
message ("MathConstant Result: %s", res1.to_string ());
- assert (res1.real () == 3.0);
+ assert (res1.@value () == 3.0);
assert (a.expressions.get_n_items () == 2);
var v = a.expressions.get_item (0) as MathVariable;
assert (v != null);
- var res2 = v.evaluate () as MathConstant;
+ var res2 = v.evaluate () as MathConstantNumber;
assert (res2 != null);
message ("MathConstant Result: %s", res2.to_string ());
- assert (res2.real () == 3.0);
+ assert (res2.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1067,17 +1067,17 @@ class Tests {
assert (eq != null);
var a = eq.expressions.get_item (0) as MathAssign;
assert (a != null);
- var res1 = a.evaluate () as MathConstant;
+ var res1 = a.evaluate () as MathConstantNumber;
assert (res1 != null);
message ("MathConstant Result: %s", res1.to_string ());
- assert (res1.real () == 48.0);
+ assert (res1.@value () == 48.0);
assert (a.expressions.get_n_items () == 2);
var v = a.expressions.get_item (0) as MathVariable;
assert (v != null);
- var res2 = v.evaluate () as MathConstant;
+ var res2 = v.evaluate () as MathConstantNumber;
assert (res2 != null);
message ("MathConstant Result: %s", res2.to_string ());
- assert (res2.real () == 48.0);
+ assert (res2.@value () == 48.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1098,9 +1098,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1122,9 +1122,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1134,9 +1134,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1158,9 +1158,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1170,9 +1170,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1195,9 +1195,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1207,9 +1207,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
var eq3 = eqman.equations.get_item (2) as MathEquation;
assert (eq3 != null);
message ("Evaluating Eq3...");
@@ -1221,9 +1221,9 @@ class Tests {
message ("Result Type: %s", res3.expression.get_type ().name ());
assert (res3.expression is MathConstant);
message ("Result: %s", res3.expression.to_string ());
- var c3 = res3.expression as MathConstant;
+ var c3 = res3.expression as MathConstantNumber;
assert (c3 != null);
- assert (c3.real () == 6.0);
+ assert (c3.@value () == 6.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1246,9 +1246,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1258,9 +1258,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
var eq3 = eqman.equations.get_item (2) as MathEquation;
assert (eq3 != null);
message ("Evaluating Eq3...");
@@ -1272,9 +1272,9 @@ class Tests {
message ("Result Type: %s", res3.expression.get_type ().name ());
assert (res3.expression is MathConstant);
message ("Result: %s", res3.expression.to_string ());
- var c3 = res3.expression as MathConstant;
+ var c3 = res3.expression as MathConstantNumber;
assert (c3 != null);
- assert (c3.real () == 30.0);
+ assert (c3.@value () == 30.0);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1297,9 +1297,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1309,9 +1309,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
var eq3 = eqman.equations.get_item (2) as MathEquation;
assert (eq3 != null);
message ("Evaluating Eq3...");
@@ -1323,9 +1323,9 @@ class Tests {
message ("Result Type: %s", res3.expression.get_type ().name ());
assert (res3.expression is MathConstant);
message ("Result: %s", res3.expression.to_string ());
- var c3 = res3.expression as MathConstant;
+ var c3 = res3.expression as MathConstantNumber;
assert (c3 != null);
- assert (c3.real () == 31.5);
+ assert (c3.@value () == 31.5);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
@@ -1349,9 +1349,9 @@ class Tests {
assert (res.expression != null);
assert (res.expression is MathConstant);
message ("Result: %s", res.expression.to_string ());
- var c = res.expression as MathConstant;
+ var c = res.expression as MathConstantNumber;
assert (c != null);
- assert (c.real () == 3.0);
+ assert (c.@value () == 3.0);
var eq2 = eqman.equations.get_item (0) as MathEquation;
assert (eq2 != null);
var res2 = eq2.solve ();
@@ -1361,9 +1361,9 @@ class Tests {
assert (res2.expression != null);
assert (res2.expression is MathConstant);
message ("Result: %s", res2.expression.to_string ());
- var c2 = res2.expression as MathConstant;
+ var c2 = res2.expression as MathConstantNumber;
assert (c2 != null);
- assert (c2.real () == 3.0);
+ assert (c2.@value () == 3.0);
var eq3 = eqman.equations.get_item (2) as MathEquation;
assert (eq3 != null);
message ("Evaluating Eq3...");
@@ -1375,9 +1375,9 @@ class Tests {
message ("Result Type: %s", res3.expression.get_type ().name ());
assert (res3.expression is MathConstant);
message ("Result: %s", res3.expression.to_string ());
- var c3 = res3.expression as MathConstant;
+ var c3 = res3.expression as MathConstantNumber;
assert (c3 != null);
- assert (c3.real () == 31.5);
+ assert (c3.@value () == 31.5);
var eq4 = eqman.equations.get_item (3) as MathEquation;
assert (eq4 != null);
message ("Evaluating Eq4...");
@@ -1389,9 +1389,9 @@ class Tests {
message ("Result Type: %s", res4.expression.get_type ().name ());
assert (res4.expression is MathConstant);
message ("Result: %s", res4.expression.to_string ());
- var c4 = res4.expression as MathConstant;
+ var c4 = res4.expression as MathConstantNumber;
assert (c4 != null);
- assert (c4.real () == 8.16);
+ assert (c4.@value () == 8.16);
} catch (GLib.Error e) {
warning ("Error: %s", e.message);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]