Package org.jruby

Examples of org.jruby.RubyInstanceConfig


        out = new PrintStream(new ByteArrayOutputStream());
        err = new PrintStream(new ByteArrayOutputStream());
    }

    public void testParsing() {
        RubyInstanceConfig c = new RubyInstanceConfig();
        c.processArguments(new String[]{"-e", "hello", "-e", "world"});
        assertEquals("hello\nworld\n", new String(c.inlineScript()));
        assertNull(c.getScriptFileName());
        assertEquals("-e", c.displayedFileName());

        c = new RubyInstanceConfig();
        c.processArguments(new String[]{"--version"});
        assertTrue(c.isShowVersion());

        c = new RubyInstanceConfig();
        c.processArguments(new String[]{"-n", "myfile.rb"});
        assertTrue(c.isAssumeLoop());
        assertEquals("myfile.rb", c.getScriptFileName());
        assertEquals("myfile.rb", c.displayedFileName());

        c = new RubyInstanceConfig();
        c.processArguments(new String[0]);
        assertEquals("-", c.displayedFileName());
    }
View Full Code Here


            public TestableCommandlineParser(String[] arguments) {
                super();
                processArguments(arguments);
            }
        }
        RubyInstanceConfig c = new TestableCommandlineParser(new String[]{"-I", "someLoadPath", "--", "simple.rb", "-v", "--version"});
        assertEquals("someLoadPath", c.getLoadPaths().get(0));
        assertEquals("simple.rb", c.getScriptFileName());
        assertEquals("simple.rb", c.displayedFileName());
        assertTrue("Should not be verbose. The -v flag should be a parameter to the script, not the jruby interpreter", !c.isVerbose());
        assertEquals("Script should have two parameters", 2, c.getArgv().length);
        assertEquals("-v", c.getArgv()[0]);
        assertEquals("--version", c.getArgv()[1]);
    }
View Full Code Here

        assertEquals("--version", c.getArgv()[1]);
    }

    public void testHelpDoesNotRunIntepreter() {
        String[] args = new String[]{"-h"};
        RubyInstanceConfig parser = new RubyInstanceConfig();
        parser.processArguments(args);
        assertFalse(parser.getShouldRunInterpreter());

        args = new String[]{"--help"};
        parser = new RubyInstanceConfig();
        parser.processArguments(args);
        assertFalse(parser.getShouldRunInterpreter());
    }
View Full Code Here

        assertFalse(parser.getShouldRunInterpreter());
    }

    public void testCommandTakesOneArgument() {
        String[] args = new String[]{"--command", "gem"};
        RubyInstanceConfig parser = new RubyInstanceConfig();
        parser.processArguments(args);
        assertNotNull(parser.getScriptFileName());
    }
View Full Code Here

        assertNotNull(parser.getScriptFileName());
    }

    public void testCommandAllowedOnlyOnceAndRemainderAreScriptArgs() {
        String[] args = new String[]{"--command", "gem", "--command", "irb"};
        RubyInstanceConfig parser = new RubyInstanceConfig();
        parser.processArguments(args);
        assertEquals(2, parser.getArgv().length);
        assertEquals("--command", parser.getArgv()[0]);
        assertEquals("irb", parser.getArgv()[1]);
    }
View Full Code Here

        assertEquals("irb", parser.getArgv()[1]);
    }

    public void testCommandExtractScript() {
        String[] args = new String[] { "-x ../../../test", "testDoc.foo"};
        RubyInstanceConfig parser = new RubyInstanceConfig();
        parser.processArguments(args);
        assertEquals(true, parser.isXFlag());
        assertEquals("testDoc.foo", parser.getScriptFileName());
    }
View Full Code Here

   
    public void testNativeENVSettingWhenItIsDisabledOnTheRuntime() throws Exception {
        if (Platform.IS_WINDOWS) {
            return;             // posix.getenv() not currently implemented
        }
        RubyInstanceConfig cfg = new RubyInstanceConfig();
        cfg.setUpdateNativeENVEnabled(false);
        runtime = Ruby.newInstance(cfg);
        runtime.evalScriptlet("ENV['biscuit'] = 'gravy'");
        assertNull(runtime.getPosix().getenv("biscuit"));
    }
View Full Code Here

        runtime.evalScriptlet("ENV['biscuit'] = 'gravy'");
        assertNull(runtime.getPosix().getenv("biscuit"));
    }
   
    public void testNativeENVSettingWhenNativeIsDisabledGlobally() throws Exception {
        RubyInstanceConfig cfg = new RubyInstanceConfig();
        cfg.setNativeEnabled(false);
        runtime = Ruby.newInstance(cfg);
        runtime.evalScriptlet("ENV['gravy'] = 'with sausage'");
        assertNull(runtime.getPosix().getenv("gravy"));
    }
View Full Code Here

        runtime.evalScriptlet("ENV['gravy'] = 'with sausage'");
        assertNull(runtime.getPosix().getenv("gravy"));
    }
   
    public void testNativeENVSettingWhenNativeIsDisabledGloballyButExplicitlyEnabledOnTheRuntime() throws Exception {
        RubyInstanceConfig cfg = new RubyInstanceConfig();
        cfg.setNativeEnabled(false);
        cfg.setUpdateNativeENVEnabled(true);
        runtime = Ruby.newInstance(cfg);
        runtime.evalScriptlet("ENV['sausage'] = 'biscuits'");
        assertNull(runtime.getPosix().getenv("sausage"));
    }
View Full Code Here

        runtime.evalScriptlet("ENV['sausage'] = 'biscuits'");
        assertNull(runtime.getPosix().getenv("sausage"));
    }
   
    public void testRequireCextNotAllowedWhenCextIsDisabledGlobally() throws Exception {
        RubyInstanceConfig cfg = new RubyInstanceConfig();
        cfg.setCextEnabled(false);
        runtime = Ruby.newInstance(cfg);
       
        String extensionSuffix;
        if (Platform.IS_WINDOWS) {
            extensionSuffix = ".dll";
View Full Code Here

TOP

Related Classes of org.jruby.RubyInstanceConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.