Package org.jruby

Examples of org.jruby.RubyInstanceConfig$Argument


            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

        }
    }
   
    public void testPrintErrorShouldPrintErrorMessageAndStacktraceWhenBacktraceIsPresent() {
        final ByteArrayOutputStream err = new ByteArrayOutputStream();
        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
            setTraceType(TraceType.traceTypeFor("mri"));
        }};
        Ruby ruby = Ruby.newInstance(config);
        RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")},  Block.NULL_BLOCK);
View Full Code Here

TOP

Related Classes of org.jruby.RubyInstanceConfig$Argument

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.