1 30 package org.jruby.test; 31 32 import junit.framework.TestCase; 33 34 import org.jruby.Ruby; 35 import org.jruby.javasupport.JavaUtil; 36 37 40 public class TestJavaUtil extends TestCase { 41 private Ruby runtime; 42 43 public TestJavaUtil(String name) { 44 super(name); 45 } 46 47 public void setUp() { 48 runtime = Ruby.getDefaultInstance(); 49 } 50 51 public void testConvertJavaToRuby() { 52 assertEquals(JavaUtil.convertJavaToRuby(runtime, null).getType().name().toString(), "NilClass"); 53 assertEquals(JavaUtil.convertJavaToRuby(runtime, new Integer (1000)).getType().name().toString(), "Fixnum"); 54 assertEquals(JavaUtil.convertJavaToRuby(runtime, new Double (1.0)).getType().name().toString(), "Float"); 55 assertEquals(JavaUtil.convertJavaToRuby(runtime, Boolean.TRUE).getType().name().toString(), "TrueClass"); 56 assertEquals(JavaUtil.convertJavaToRuby(runtime, Boolean.FALSE).getType().name().toString(), "FalseClass"); 57 assertEquals(JavaUtil.convertJavaToRuby(runtime, "AString").getType().name().toString(), "String"); 58 } 59 } 60 | Popular Tags |