Examples of newArgumentError()


Examples of org.jruby.Ruby.newArgumentError()

                int gval = argc == 2 ? RubyNumeric.fix2int(args[1]) : 2;
                BigInteger p;
                try {
                    p = generateP(bits, gval);
                } catch(IllegalArgumentException e) {
                    throw runtime.newArgumentError(e.getMessage());
                }
                BigInteger g = BigInteger.valueOf(gval);
                BigInteger x = generateX(p);
                BigInteger y = generateY(p, g, x);
                this.dh_p = p;
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

    @JRubyMethod(name = "wait", required = 1, optional = 1)
    public IRubyObject wait_ruby(ThreadContext context, IRubyObject[] args) {
        Ruby runtime = context.runtime;
        if (args.length < 1) {
            throw runtime.newArgumentError(args.length, 1);
        }
        if (args.length > 2) {
            throw runtime.newArgumentError(args.length, 2);
        }
        if (!(args[0] instanceof Mutex)) {
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        Ruby runtime = context.runtime;
        if (args.length < 1) {
            throw runtime.newArgumentError(args.length, 1);
        }
        if (args.length > 2) {
            throw runtime.newArgumentError(args.length, 2);
        }
        if (!(args[0] instanceof Mutex)) {
            throw context.runtime.newTypeError(args[0], runtime.getClass("Mutex"));
        }
        Mutex mutex = (Mutex) args[0];
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        Mutex mutex = (Mutex) args[0];
        Double timeout = null;
        if (args.length > 1 && !args[1].isNil()) {
            timeout = args[1].convertToFloat().getDoubleValue();
            if (timeout < 0) {
                throw runtime.newArgumentError("time interval must be positive");
            }
        }
        if (Thread.interrupted()) {
            throw runtime.newConcurrencyError("thread interrupted");
        }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

            if (!arg.isNil()) {
                if (!(arg instanceof RubyFixnum)) {
                    throw runtime.newTypeError(arg, runtime.getFixnum());
                }
                if (0 > ((RubyFixnum)arg).getLongValue()) {
                    throw runtime.newArgumentError("argument must be positive");
                }
                c.setInternalModuleVariable("vpPrecLimit", arg);
            }
        }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

            MathContext context = MathContext.UNLIMITED;

            if (args.length == 2) {
                int digits = (int)args[1].convertToInteger().getLongValue();
                if (digits < 0) {
                    throw runtime.newArgumentError("argument must be positive");
                }
                context = new MathContext(digits);
            }

            if (runtime.is1_9()) {
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

                if (args[0] instanceof RubyBigDecimal) {
                    return new RubyBigDecimal(runtime, (RubyClass)recv, ((RubyBigDecimal)args[0]));
                } else if (args[0] instanceof RubyFloat || args[0] instanceof RubyRational) {
                    if (args.length != 2) {
                        // float input must be accompanied by precision
                        throw runtime.newArgumentError("can't omit precision for a rational");
                    }

                    if (args[0] instanceof RubyFloat) {
                        // precision can be no more than float digits
                        if (context.getPrecision() > RubyFloat.DIG + 1) {
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

                    }

                    if (args[0] instanceof RubyFloat) {
                        // precision can be no more than float digits
                        if (context.getPrecision() > RubyFloat.DIG + 1) {
                            throw runtime.newArgumentError("precision too large");
                        }
                        return new RubyBigDecimal(runtime, (RubyClass)recv, new BigDecimal(((RubyFloat)args[0]).getDoubleValue(), context));
                    } else {
                        RubyRational rat = (RubyRational)args[0];
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        Ruby runtime = context.runtime;

        if (arg instanceof RubyFixnum) {
            int value = RubyNumeric.fix2int(arg);
            if (value < 0) {
                throw runtime.newArgumentError("argument must be positive");
            }
            return value;
        } else {
            throw runtime.newTypeError(arg, runtime.getFixnum());
        }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        // NOTE: MRI's sqrt precision is limited by 100,
        // but we allow values more than 100.
        int n = RubyNumeric.fix2int(arg);
        if (n < 0) {
            throw runtime.newArgumentError("argument must be positive");
        }

        n += 4; // just in case, add a bit of extra precision

        return new RubyBigDecimal(getRuntime(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.