1 package org.jruby.test; 2 3 import junit.framework.TestCase; 4 5 import org.jruby.Ruby; 6 import org.jruby.exceptions.RaiseException; 7 8 public class TestVariableCreation extends TestCase { 9 private static Ruby r; 10 private static RaiseException failed; 11 public void testLocalVars() { 12 r = Ruby.getDefaultInstance(); 13 r.evalScript("a = 1\n"); 15 r.evalScript("a.to_s"); 16 17 Runnable run = new Runnable (){ 19 public void run(){ 20 try { 21 r.evalScript("a.to_s"); 22 } catch(RaiseException ex){ 23 failed = ex; 24 } 25 } 26 }; 27 Thread n = new Thread (run); 28 29 n.start(); 30 try { 31 n.join(); 32 assertNotNull(failed); 33 assertEquals("NameError", failed.getException().getMetaClass().getName()); 34 } catch (InterruptedException e) { 35 fail(); 36 } 37 38 39 40 41 } 42 43 } 44 | Popular Tags |