new Hash("key","value","bool",true,"int,42,....) toJavascript() {key:'value',bool:true,int:42} toAttributesString() key="value" bool="true" int="42"
678910111213
public class HashTest extends TestCase { public void testEscape(){ Hash h = new Hash("key","<&>"); assertEquals(" key=\"<&>\"", h.asCharSequence()); }
1112131415161718192021
Hash h = new Hash("key","<&>"); assertEquals(" key=\"<&>\"", h.asCharSequence()); } public void testFail(){ try { new Hash("key"); fail("should raise ex"); } catch (IllegalArgumentException iex) { assertTrue(true); }
1920212223242526
assertTrue(true); } } public void testJavascript(){ Hash h = new Hash("key","value"); assertEquals("{key:'value'}", h.toJavascript()); }
2324252627282930
public void testJavascript(){ Hash h = new Hash("key","value"); assertEquals("{key:'value'}", h.toJavascript()); } public void testMultiKey(){ Hash h = new Hash("key","value","key2","value2"); assertTrue(h.toJavascript().indexOf("value2") != -1); }
2728293031323334
public void testMultiKey(){ Hash h = new Hash("key","value","key2","value2"); assertTrue(h.toJavascript().indexOf("value2") != -1); } public void testJavascriptBoolean(){ Hash h = new Hash("bool",true); assertEquals("{bool:true}", h.toJavascript()); }
3132333435363738
public void testJavascriptBoolean(){ Hash h = new Hash("bool",true); assertEquals("{bool:true}", h.toJavascript()); } public void testJavascriptInt(){ Hash h = new Hash("int",42); assertEquals("{int:42}", h.toJavascript()); }
2223242526272829
} // public JQueryCanvas $() { return new JQueryCanvas(); } public void testSetup() { JQueryCanvas jc = $().ajaxSetup(new Hash("cache",false)); System.out.println(jc.toJavascript()); }