You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2016/10/07 11:49:34 UTC

svn commit: r1763746 - in /uima/ruta/trunk/ruta-core/src: main/java/org/apache/uima/ruta/expression/number/ test/java/org/apache/uima/ruta/expression/number/

Author: pkluegl
Date: Fri Oct  7 11:49:34 2016
New Revision: 1763746

URL: http://svn.apache.org/viewvc?rev=1763746&view=rev
Log:
UIMA-5131
- fixed for trivial case (which covers actually 90%)
- added test

Added:
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java   (with props)
Modified:
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java?rev=1763746&r1=1763745&r2=1763746&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ComposedNumberExpression.java Fri Oct  7 11:49:34 2016
@@ -85,7 +85,11 @@ public class ComposedNumberExpression ex
 
   @Override
   public String getStringValue(MatchContext context, RutaStream stream) {
-    return "" + getDoubleValue(context, stream);
+    if(ops.isEmpty() && expressions.size() == 1) {
+      return expressions.get(0).getStringValue(context, stream);
+    } else {
+      return String.valueOf(getDoubleValue(context, stream));
+    }
   }
 
   public List<INumberExpression> getExpressions() {

Added: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java?rev=1763746&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java (added)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java Fri Oct  7 11:49:34 2016
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.ruta.expression.number;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ComposedNumberExpressionTest {
+
+  @Test
+  public void testGetStringValueWithInteger() {
+    List<INumberExpression> list = new ArrayList<>();
+    list.add(new SimpleNumberExpression(Integer.valueOf(1)));
+    ComposedNumberExpression expr = new ComposedNumberExpression(list, new ArrayList<String>());
+    String string = expr.getStringValue(null, null);
+    Assert.assertEquals("1", string);
+  }
+  
+}

Propchange: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/number/ComposedNumberExpressionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native