felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r807497 - in /felix/trunk/gogo/runtime/src: main/java/org/apache/felix/gogo/runtime/shell/Closure.java test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
Date Tue, 25 Aug 2009 06:34:31 GMT
Author: gnodet
Date: Tue Aug 25 06:34:31 2009
New Revision: 807497

URL: http://svn.apache.org/viewvc?rev=807497&view=rev
Log:
FELIX-1325: gogo doesn't report a command not found error unless an argument is supplied

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java?rev=807497&r1=807496&r2=807497&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
Tue Aug 25 06:34:31 2009
@@ -184,6 +184,15 @@
                 {
                     return session.variables.remove(scmd);
                 }
+                else if (values.size() == 2)
+                {
+                    Object value = values.get(1);
+                    if (value instanceof CharSequence)
+                    {
+                        value = eval((CharSequence) value);
+                    }
+                    return assignment(scmd, value);
+                }
                 else
                 {
                     Object value = execute(values.get(1), values.subList(2, values.size()));
@@ -203,10 +212,6 @@
                     x = get(scopedFunction);
                     if (x == null || !(x instanceof Function))
                     {
-                        if (values.isEmpty())
-                        {
-                            return scmd;
-                        }
                         throw new IllegalArgumentException("Command not found:  " + scopedFunction);
                     }
                 }
@@ -438,10 +443,11 @@
 
     private Object var(CharSequence var) throws Exception
     {
-        Object v = eval(var);
-        if (v instanceof Closure) {
-            v = ((Closure) v).execute(session, null);
+        if (var.charAt(0) == '{')
+        {
+            var = var.subSequence(1, var.length() - 1);
         }
+        Object v = eval(var);
         String name = v.toString();
         return get(name);
     }

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java?rev=807497&r1=807496&r2=807497&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
(original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
Tue Aug 25 06:34:31 2009
@@ -35,7 +35,8 @@
 {
     int beentheredonethat = 0;
 
-    public void testEvaluatation() throws Exception {
+    public void testEvaluatation() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.addCommand("capture", this);
@@ -45,14 +46,30 @@
         assertEquals("a", c.execute("<<echo a>> | capture"));
     }
 
-    public void testSpecialValues() throws Exception {
+    public void testUnknownCommand() throws Exception
+    {
+        Context c = new Context();
+        try
+        {
+            c.execute("echo");
+            fail("Execution should have failed due to missing command");
+        }
+        catch (IllegalArgumentException e)
+        {
+            // expected
+        }
+    }
+
+    public void testSpecialValues() throws Exception
+    {
         Context c = new Context();
         assertEquals(false, c.execute("false"));
         assertEquals(true, c.execute("true"));
         assertEquals(null, c.execute("null"));
     }
 
-    public void testQuotes() throws Exception {
+    public void testQuotes() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.set("c", "a");



Mime
View raw message