package org.libj.xquery;

import org.junit.Test;

import static org.libj.xquery.Asserts.*;

public class TestFreeVariables {
    @Test
    public void testSimple() {
        Environment env = new Environment();
        env.putVariable("i", 1);
        env.putVariable("j", 7);
        env.putVariable("s", "abc");
        assertEval("$i", 1, env);
        assertEval("$j", 7, env);
        assertEval("$i + 3", 4, env);
        assertEval("$i + 3 + $j", 11, env);
        assertEval("$s", "abc", env);
        assertEvalString("<x>{$s}</x>", "<x>abc</x>", env);
        assertEvalString("<x>{$i}{$j}</x>", "<x>17</x>", env);
    }
    @Test
    public void testOverride() {
        Environment env = new Environment();
        env.putVariable("i", 1);
        env.putVariable("j", 7);
        env.putVariable("s", "abc");
        assertEvalString("for $i in 1 to 10 return $i + $j", "8 9 10 11 12 13 14 15 16 17", env);
    }
}

@@ -126,52 +126,15 @@
     
-@Test%0A    public void testSimple() %7B%0A       
+private
  Env
@@ -159,32 +159,65 @@
  Environment();%0A
+    public TestFreeVariables() %7B%0A
         env.putV
@@ -295,32 +295,79 @@
 le(%22s%22, %22abc%22);%0A
+    %7D%0A    @Test%0A    public void testSimple() %7B%0A
         assertEv
@@ -714,156 +714,8 @@
 ) %7B%0A
-        Environment env = new Environment();%0A        env.putVariable(%22i%22, 1);%0A        env.putVariable(%22j%22, 7);%0A        env.putVariable(%22s%22, %22abc%22);%0A
     

remove duplicate code