aboutsummaryrefslogblamecommitdiff
path: root/libraries/eval/test/EvalTest.scala
blob: 356ef80e53dd10a476b4d4bfd0e6eeb3754aa374 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                              
                                       

                                            
                            
                                                  

   





                                    
                                                     
     

                                              
                                                                                   

                                 



                                                                              

   
package com.twitter.util

import org.specs.Specification
import java.io.{File, FileOutputStream}

object EvaluatorSpec extends Specification {
  def file(path: String) = {
    new File("util-eval/src/test/resources", path)
  }

  "Evaluator" should {
    "apply('expression')" in {
      Eval[Int]("1 + 1") mustEqual 2
    }

    "apply(new File(...))" in {
      Eval[Int](file("OnePlusOne.scala")) mustEqual 2
    }

    "apply(new File(...), new File(...))" in {
      val derived = Eval[() => String](file("/Base.scala"), file("/Derived.scala"))
      derived() mustEqual "hello"
    }

    "apply(InputStream)" in {
      Eval[Int](getClass.getResourceAsStream("/OnePlusOne.scala")) mustEqual 2
    }
  }
}