org.scalatest.matchers.Matchers

class ResultOfLengthWordApplication

[source: org/scalatest/matchers/Matchers.scala]

final class ResultOfLengthWordApplication(val expectedLength : Long)
extends HavePropertyMatcher[AnyRef, Long] with AnyRef
This class is part of the ScalaTest matchers DSL. Please see the documentation for ShouldMatchers or MustMatchers for an overview of the matchers DSL.
Author
Bill Venners
Method Summary
def apply (objectWithProperty : AnyRef) : HavePropertyMatchResult[Long]
This method enables the following syntax:
     "hi" should not have (length (3))
                          ^
     
Methods inherited from scala.Function1
scala.Function1.toString, scala.Function1.compose, scala.Function1.andThen
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def apply(objectWithProperty : AnyRef) : HavePropertyMatchResult[Long]
This method enables the following syntax:
     "hi" should not have (length (3))
                          ^
     

This reason ResultOfLengthWordApplication is a HavePropertyMatcher[AnyRef, Long] is so that you don't have to remember whether length needs to be surrounded by parentheses when following have. Only length and size can be used without parentheses: everything else needs the parentheses. So this approach means that if you use the unneeded parentheses with length and size, it will still work. This apply method uses reflection to find and access the length property on the passed objectWithProperty. Therefore if the object does not have the appropriate structure, the expression will compile, but at will produce a TestFailedException at runtime.

Overrides
HavePropertyMatcher.apply


Copyright (C) 2001-2010 Artima, Inc. All rights reserved.