org.scalatest.matchers.Matchers

class ResultOfSizeWordApplication

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

final class ResultOfSizeWordApplication(val expectedSize : 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:
     set should not have (size (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:
     set should not have (size (3))
                         ^
     

This reason ResultOfSizeWordApplication is a HavePropertyMatcher[AnyRef, Long] is so that you don't have to remember whether size 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 size 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-2009 Artima, Inc. All rights reserved.