@Test public void testConvertInt() throws Exception { FloatRhsFunction f = new FloatRhsFunction(); Symbol result = f.execute(rhsFuncContext, Symbols.asList(syms, 3)); assertEquals(3.0, result.asDouble().getValue(), 0.0001); }
public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final Symbol arg = arguments.get(0); final DoubleSymbol doubleSym = arg.asDouble(); if(doubleSym != null) { return doubleSym; } final IntegerSymbol intSym = arg.asInteger(); if(intSym != null) { return context.getSymbols().createDouble(intSym.getValue()); } if(arg.asIdentifier() != null) { throw new RhsFunctionException("Identifier passed to float RHS function: " + arg); } final String string = arg.toString(); try { return context.getSymbols().createDouble(Double.parseDouble(string)); } catch(NumberFormatException e) { throw new RhsFunctionException(arg + " is not a valid float."); } }
FloatRhsFunction extends AbstractRhsFunctionHandler { public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final Symbol arg = arguments.get(0); final DoubleSymbol doubleSym = arg.asDouble(); if(doubleSym != null) { return doubleSym; } final IntegerSymbol intSym = arg.asInteger(); if(intSym != null) { return context.getSymbols().createDouble(intSym.getValue()); } if(arg.asIdentifier() != null) { throw new RhsFunctionException("Identifier passed to float RHS function: " + arg); } final String string = arg.toString(); try { return context.getSymbols().createDouble(Double.parseDouble(string)); } catch(NumberFormatException e) { throw new RhsFunctionException(arg + " is not a valid float."); } } }
FloatRhsFunction extends AbstractRhsFunctionHandler { public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final Symbol arg = arguments.get(0); final DoubleSymbol doubleSym = arg.asDouble(); if(doubleSym != null) { return doubleSym; } final IntegerSymbol intSym = arg.asInteger(); if(intSym != null) { return context.getSymbols().createDouble(intSym.getValue()); } if(arg.asIdentifier() != null) { throw new RhsFunctionException("Identifier passed to float RHS function: " + arg); } final String string = arg.toString(); try { return context.getSymbols().createDouble(Double.parseDouble(string)); } catch(NumberFormatException e) { throw new RhsFunctionException(arg + " is not a valid float."); } } FloatRhsFunction(); }
FloatRhsFunction extends AbstractRhsFunctionHandler { public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final Symbol arg = arguments.get(0); final DoubleSymbol doubleSym = arg.asDouble(); if(doubleSym != null) { return doubleSym; } final IntegerSymbol intSym = arg.asInteger(); if(intSym != null) { return context.getSymbols().createDouble(intSym.getValue()); } if(arg.asIdentifier() != null) { throw new RhsFunctionException("Identifier passed to float RHS function: " + arg); } final String string = arg.toString(); try { return context.getSymbols().createDouble(Double.parseDouble(string)); } catch(NumberFormatException e) { throw new RhsFunctionException(arg + " is not a valid float."); } } FloatRhsFunction(); Symbol execute(RhsFunctionContext context, List<Symbol> arguments); }
FloatRhsFunction extends AbstractRhsFunctionHandler { public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final Symbol arg = arguments.get(0); final DoubleSymbol doubleSym = arg.asDouble(); if(doubleSym != null) { return doubleSym; } final IntegerSymbol intSym = arg.asInteger(); if(intSym != null) { return context.getSymbols().createDouble(intSym.getValue()); } if(arg.asIdentifier() != null) { throw new RhsFunctionException("Identifier passed to float RHS function: " + arg); } final String string = arg.toString(); try { return context.getSymbols().createDouble(Double.parseDouble(string)); } catch(NumberFormatException e) { throw new RhsFunctionException(arg + " is not a valid float."); } } FloatRhsFunction(); Symbol execute(RhsFunctionContext context, List<Symbol> arguments);  }