-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.scala
More file actions
44 lines (30 loc) · 798 Bytes
/
Test.scala
File metadata and controls
44 lines (30 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package test
import language.implicitConversions
class Test[T](val target:T) {
def tst[E](expected:E)(test: => Boolean){
//println(target)
if(test == false) {
val msg = "[Error] expected: " + expected + " but found " + target
println(msg)
}else {
val msg = "Test Ok! the result is " + expected
println(msg)
}
}
def str = // Safely convert to a String
Option(target).getOrElse("").toString
def is(expected:String) = tst(expected) {
expected.replaceAll("\r\n","\n") == str
}
def is[E](expected:E) = tst(expected) {
expected == target
}
def beginsWith(exp:String) = tst(exp) {
str.startsWith(
exp.replaceAll("\r\n","\n"))
}
}
object Test {
implicit def any2Atomic[T](target:T) =
new Test(target)
}