/** 
 * Copyright 2006-2007 Yu Su, Yu Zhang
 * Distributed under the GNU General Public License 2.0
 */

package com.xruby.runtime.javasupport;

import com.xruby.compiler.RubyCompiler;
import com.xruby.compiler.codegen.CompilationResults;
import com.xruby.runtime.lang.*;
import java.io.StringReader;

/**
 *
 */
public class RequireExample {
	public static void main(String[] args) throws Exception {

        String program_text = "" +
                "import 'java.util.*'\n" +
                "r = Random.new" + "\n" +
                "puts r.nextInt\n" +
                "puts r.nextInt(3)\n" +
                "array = ArrayList.new\n" +
                "array.add 1\n" +
                "array.add 2\n" +
                "array.add 3\n" +
                "for i in 1 ... 3\n" +
                "    puts array.get(i)\n" +
                "end";
        
        RubyCompiler compiler = new RubyCompiler(null, false);
		CompilationResults codes = compiler.compile(new StringReader(program_text));
		RubyProgram p = codes.getRubyProgram();

		RubyRuntime.init(args);
		p.invoke();
		RubyRuntime.fini();

    }
}



@@ -512,24 +512,66 @@
 w%22 + %22%5Cn%22 +%0A
+                //call overloaded methods%0A
             
@@ -655,241 +655,1754 @@
     
-%22array = ArrayList.new%5Cn%22 +%0A                %22array.add 1%5Cn%22 +%0A                %22array.add 2%5Cn%22 +%0A                %22array.add 3%5Cn%22 +%0A                %22for i in 1 ... 3%5Cn%22 +%0A                %22    puts array.get(i)%5Cn%22 +%0A                %22end
+//call methods inherited superclass(for example:Object)%0A                %22puts r.toString%5Cn%22 +%0A                %0A                %0A                //call static methods and fields%0A                %22import 'java.lang.Math'%5Cn%22+%0A                %22puts JMath.PI%5Cn%22+%0A                %22puts JMath.cos(0)%5Cn%22+%0A                %0A                %0A                //access Java constant variables%0A                %22import 'java.lang.System'%5Cn%22+%0A                %22out = System::out%5Cn%22+%0A                %22out.println('ok!')%5Cn%22+%0A                %0A                %0A                //escape from name collision%0A                %22import 'java.lang.Object'%5Cn%22+%0A                %22o = JObject.new%5Cn%22 +%0A                %22puts o.toString%5Cn%22 +%0A                %0A                %0A                //implement a Java interface%0A                %22require_java 'java.lang.Runnable'%5Cn%22+%0A                %22require_java 'java.lang.Thread'%5Cn%22+%0A                %22class MyRunnable %3C Runnable%5Cn%22+%0A                %22   def run%5Cn%22+%0A                %22       puts 'ok'%5Cn%22+%0A                %22   end%5Cn%22+%0A                %22end%5Cn%22+%0A                %22r = MyRunnable.new%5Cn%22+%0A                %22thread = JThread.new(r)%5Cn%22+%0A                %22thread.start()%5Cn%22+%0A%0A                %22array = ArrayList.new%5Cn%22 +%0A                %22array.add 1%5Cn%22 +%0A                %22array.add 2%5Cn%22 +%0A                %22array.add 3%5Cn%22 +%0A                %22for i in 1 ... 3%5Cn%22 +%0A                %22    puts array.get(i)%5Cn%22 +%0A                %22end%5Cn%22+%0A                %0A                //JavaBean support%0A                %22import 'javax.swing.JFrame'%5Cn%22+%0A                %22f = JFrame.new('hello')%5Cn%22+%0A                //calls setVisible%0A                %22f.visible= true%5Cn%22+%0A                //calls getTitle%0A                %22puts f.title%5Cn%22+%0A                %22%5Cn
 %22;%0A 

add some test examples