Search in sources :

Example 6 with Context

use of org.nutz.lang.util.Context in project nutz by nutzam.

the class El2Test method testIssues87.

@Test
public void testIssues87() {
    Context context = Lang.context();
    context.set("a", new BigDecimal("7"));
    context.set("b", new BigDecimal("3"));
    assertEquals(10, El.eval(context, "a.add(b).intValue()"));
}
Also used : Context(org.nutz.lang.util.Context) BigDecimal(java.math.BigDecimal) SimpleSpeedTest(org.nutz.el.speed.SimpleSpeedTest) Test(org.junit.Test)

Example 7 with Context

use of org.nutz.lang.util.Context in project nutz by nutzam.

the class El2Test method testIssue308.

@Test
public void testIssue308() {
    Context context = Lang.context();
    List<String> list = new ArrayList<String>();
    list.add("jk");
    context.set("list", list);
    context.set("System", System.class);
    El.eval(context, "System.getenv('PATH').getClass().getName()");
    assertEquals("1", Mirror.me(String.class).invoke(String.class, "valueOf", 1));
    assertEquals("jk", Mirror.me(String.class).invoke(String.class, "valueOf", "jk"));
}
Also used : Context(org.nutz.lang.util.Context) ArrayList(java.util.ArrayList) SimpleSpeedTest(org.nutz.el.speed.SimpleSpeedTest) Test(org.junit.Test)

Example 8 with Context

use of org.nutz.lang.util.Context in project nutz by nutzam.

the class El2Test method testIssue307.

@Test
public void testIssue307() {
    Context context = Lang.context();
    List<String> list = new ArrayList<String>();
    list.add("jk");
    context.set("list", list);
    context.set("System", System.class);
    El.eval(context, "list.add(list.get(0))");
    assertEquals(2, list.size());
}
Also used : Context(org.nutz.lang.util.Context) ArrayList(java.util.ArrayList) SimpleSpeedTest(org.nutz.el.speed.SimpleSpeedTest) Test(org.junit.Test)

Example 9 with Context

use of org.nutz.lang.util.Context in project nutz by nutzam.

the class El2Test method testIssue277.

@Test
public void testIssue277() {
    Context context = Lang.context();
    context.set("strings", Strings.class);
    assertEquals("a", El.eval(context, "strings.trim(\"  a  \")"));
}
Also used : Context(org.nutz.lang.util.Context) SimpleSpeedTest(org.nutz.el.speed.SimpleSpeedTest) Test(org.junit.Test)

Example 10 with Context

use of org.nutz.lang.util.Context in project nutz by nutzam.

the class El2Test method test_el_issue1185.

@Test(timeout = 5000, expected = Exception.class)
public void test_el_issue1185() {
    Context context = Lang.context();
    El.eval(context, "a.b)*0.30");
}
Also used : Context(org.nutz.lang.util.Context) SimpleSpeedTest(org.nutz.el.speed.SimpleSpeedTest) Test(org.junit.Test)

Aggregations

Context (org.nutz.lang.util.Context)40 Test (org.junit.Test)29 SimpleSpeedTest (org.nutz.el.speed.SimpleSpeedTest)24 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)3 ServletContext (javax.servlet.ServletContext)3 El (org.nutz.el.El)3 Map (java.util.Map)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BigDecimal (java.math.BigDecimal)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1 Ignore (org.junit.Ignore)1 ElException (org.nutz.el.ElException)1 Issue293 (org.nutz.el.issue.Issue293)1 Issue303 (org.nutz.el.issue.Issue303)1