Package com.lastcalc

Examples of com.lastcalc.TokenList


        return ParseResult.fail();
      final List<Object> list = (List<Object>) datastructure;
      ret = Lists.newArrayListWithCapacity(list.size() * 4);
      ret.add("[");
      for (final Object o : list) {
        final TokenList result = context.parseEngine.parseAndGetLastStep(
            udp.parse(TokenList.createD(o), 0).output, context);
        if (result.size() != 1 || !(result.get(0) instanceof Boolean))
          return ParseResult.fail();
        if (result.get(0).equals(true)) {
          ret.add(o);
          ret.add(",");
        }
      }
      ret.set(ret.size() - 1, "]"); // Overwrite last comma
View Full Code Here


    final boolean condition = (Boolean) tokens.get(templatePos + 1);
    final int end = PreParser.findEdgeOrObjectForwards(tokens, templatePos + 2, null) + 1;
    final int elsePos = PreParser.findEdgeOrObjectForwards(tokens, templatePos + 2, "else");
    if (!tokens.get(elsePos).equals("else"))
      return ParseResult.fail();
    TokenList ret;
    if (condition) {
      ret = new TokenList.SubTokenList(tokens, templatePos + 3, elsePos);
    } else {
      ret = new TokenList.SubTokenList(tokens, elsePos + 1, end);
    }
View Full Code Here

            worksheetRequest.questions.put(2,"double 5");
            WorksheetServlet.getWorksheetResponse(worksheet, worksheetRequest, "");
        }


        final TokenList result=worksheet.qaPairs.get(1).answer;


        Assert.assertEquals(1, result.size());

        Assert.assertTrue("Assert that " + result.get(0).getClass() + " is a Number", result.get(0) instanceof org.jscience.mathematics.number.Number);
        double value = ((Number) result.get(0)).doubleValue();
        Assert.assertEquals(10.0, value,0.01);

        System.out.println("worksheet servlet test finished");

    }
View Full Code Here

TOP

Related Classes of com.lastcalc.TokenList

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.