Page 260 (PDF page 300):
import junit.framework.TestCase
import junit.framework.Assert.assertEquals
import junit.framework.Assert.fail
import Element.elem
class ElementTestCase extends TestCase {
def testUniformElement() {
val ele = elem('x', 2, 3)
assertEquals(2, ele.width)
assertEquals(3, ele.height)
try {
elem('x', -2, 3)
fail()
}
catch {
case e: IllegalArgumentException => // expected
}
}
}
The IllegalArgumentException will never be raised(there are no illegal
argument) but // expected comment can make people confused.
|