[gnome-calculator] GCalc: null parameter adds $ prefix to its name
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] GCalc: null parameter adds $ prefix to its name
- Date: Mon, 4 Nov 2019 19:01:59 +0000 (UTC)
commit bc68389200aaba41137ac3dee3d4ae53c52b3f38
Author: Daniel Espinosa <esodan gmail com>
Date: Mon Nov 4 12:59:10 2019 -0600
GCalc: null parameter adds $ prefix to its name
If a parameter's value is null, its string representation
return its name with a '$' prefix, in order to identify
a parameter and no a variable in a math expression
gcalc/gcalc-parameter.vala | 2 +-
tests/gcalc-parsing.vala | 2 +-
tests/gcalc-solving-basic.vala | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gcalc/gcalc-parameter.vala b/gcalc/gcalc-parameter.vala
index a95eaf10..9a17f76e 100644
--- a/gcalc/gcalc-parameter.vala
+++ b/gcalc/gcalc-parameter.vala
@@ -56,7 +56,7 @@ public class GCalc.Parameter : GCalc.Variable, MathParameter {
// Expression
internal override string to_string () {
if (@value == null) {
- return name;
+ return "$"+name;
}
return @value.to_string ();
}
diff --git a/tests/gcalc-parsing.vala b/tests/gcalc-parsing.vala
index b102ac48..19294c4f 100644
--- a/tests/gcalc-parsing.vala
+++ b/tests/gcalc-parsing.vala
@@ -1138,7 +1138,7 @@ class Tests {
var v2 = t2.expressions.get_item (0) as MathVariable;
assert (v2 != null);
message (eq.to_string ());
- assert (eq.to_string () == "x=param1");
+ assert (eq.to_string () == "x=$param1");
p.set_value (10.0);
message (eq.to_string ());
assert (eq.to_string () == "x=10");
diff --git a/tests/gcalc-solving-basic.vala b/tests/gcalc-solving-basic.vala
index 73c7d08b..3b8b9a3a 100644
--- a/tests/gcalc-solving-basic.vala
+++ b/tests/gcalc-solving-basic.vala
@@ -1594,7 +1594,7 @@ class Tests {
assert (p != null);
assert (p is MathParameter);
message ("Param without value to string: %s", p.to_string ());
- assert (p.to_string () == "p");
+ assert (p.to_string () == "$p");
p.set_value (3.0);
message ("Param with value to string: %s", p.to_string ());
assert (p.to_string () == "3");
@@ -1610,7 +1610,7 @@ class Tests {
assert (c2.@value () == 9.0);
p.set_value (null);
message ("Param without value to string: %s", p.to_string ());
- assert (p.to_string () == "p");
+ assert (p.to_string () == "$p");
var res3 = eq.solve ();
if (res3 is ErrorResult) {
warning ("Error: %s", (res3 as ErrorResult).message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]