コード例 #1
0
  @Test
  public void testBasicIntp() {
    assertEquals(
        InterpreterResult.Code.SUCCESS, repl.interpret("val a = 1\nval b = 2", context).code());

    // when interpret incomplete expression
    InterpreterResult incomplete = repl.interpret("val a = \"\"\"", context);
    assertEquals(InterpreterResult.Code.INCOMPLETE, incomplete.code());
    assertTrue(incomplete.message().length() > 0); // expecting some error
    // message
  }
コード例 #2
0
 @Test
 public void testReferencingUndefinedVal() {
   InterpreterResult result =
       repl.interpret(
           "def category(min: Int) = {" + "    if (0 <= value) \"error\"" + "}", context);
   assertEquals(Code.ERROR, result.code());
 }
コード例 #3
0
 @Test
 public void testBasicScalding() {
   assertEquals(
       InterpreterResult.Code.SUCCESS,
       repl.interpret(
               "case class Sale(state: String, name: String, sale: Int)\n"
                   + "val salesList = List(Sale(\"CA\", \"A\", 60), Sale(\"CA\", \"A\", 20), Sale(\"VA\", \"B\", 15))\n"
                   + "val salesPipe = TypedPipe.from(salesList)\n"
                   + "val results = salesPipe.map{x => (1, Set(x.state), x.sale)}.\n"
                   + "    groupAll.sum.values.map{ case(count, set, sum) => (count, set.size, sum) }\n"
                   + "results.dump",
               context)
           .code());
 }
コード例 #4
0
 @Test
 public void testEndWithComment() {
   assertEquals(
       InterpreterResult.Code.SUCCESS, repl.interpret("val c=1\n//comment", context).code());
 }
コード例 #5
0
 @Test
 public void testNextLineInvocation() {
   assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("\"123\"\n.toInt", context).code());
 }