commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject commons-numbers git commit: Singletons for common values.
Date Thu, 25 May 2017 01:33:27 GMT
Repository: commons-numbers
Updated Branches:
  refs/heads/master e4c21beac -> 6fd55c8cc


Singletons for common values.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/6fd55c8c
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/6fd55c8c
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/6fd55c8c

Branch: refs/heads/master
Commit: 6fd55c8cc6394c1ba77e81cab3dd60c29a14f581
Parents: e4c21be
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
Authored: Thu May 25 03:32:38 2017 +0200
Committer: Gilles Sadowski <gilles@harfang.homelinux.org>
Committed: Thu May 25 03:32:38 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/numbers/angle/PlaneAngle.java   | 6 ++++--
 .../org/apache/commons/numbers/angle/PlaneAngleTest.java    | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/6fd55c8c/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
index 1820b62..1385ea1 100644
--- a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
+++ b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
@@ -30,10 +30,12 @@ public class PlaneAngle {
     private static final double TO_DEGREES = 360;
     /** Conversion factor. */
     private static final double FROM_DEGREES = 1d / TO_DEGREES;
-    /** Zero. */
-    private static final PlaneAngle ZERO = new PlaneAngle(0);
     /** Value (in turns). */
     private final double value;
+    /** Zero. */
+    public static final PlaneAngle ZERO = new PlaneAngle(0);
+    /** &pi; radians. */
+    public static final PlaneAngle PI = new PlaneAngle(HALF_TURN);
 
     /**
      * @param value Value in turns.

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/6fd55c8c/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
index 61b72f7..42fa94a 100644
--- a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
@@ -133,4 +133,13 @@ public class PlaneAngleTest {
         final PlaneAngle b = PlaneAngle.ofRadians(value + 1e-16);
         Assert.assertFalse(a.equals(b));
     }
+
+    @Test
+    public void testZero() {
+        Assert.assertEquals(0, PlaneAngle.ZERO.toRadians(), 0d);
+    }
+    @Test
+    public void testPi() {
+        Assert.assertEquals(Math.PI, PlaneAngle.PI.toRadians(), 0d);
+    }
 }


Mime
View raw message