The R Project SVN R

Rev

Rev 76306 | Rev 77774 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 76306 Rev 76688
Line 12... Line 12...
12
  \code{\link{all}} \code{TRUE}, \code{\link{stop}} is called, producing
12
  \code{\link{all}} \code{TRUE}, \code{\link{stop}} is called, producing
13
  an error message indicating the \emph{first} expression which was not
13
  an error message indicating the \emph{first} expression which was not
14
  (\code{\link{all}}) true.
14
  (\code{\link{all}}) true.
15
}
15
}
16
\usage{
16
\usage{
17
stopifnot(\dots, exprs, local = TRUE)
17
stopifnot(\dots, exprs, exprObject, local = TRUE)
18
}
18
}
19
\arguments{
19
\arguments{
20
  \item{\dots, exprs}{any number of (typically but not necessarily
20
  \item{\dots, exprs}{any number of (typically but not necessarily
21
    \code{\link{logical}}) \R expressions, which should each evaluate to
21
    \code{\link{logical}}) \R expressions, which should each evaluate to
22
    (a logical vector of all)
22
    (a logical vector of all)
Line 26... Line 26...
26
   expr1
26
   expr1
27
   expr2
27
   expr2
28
   ....
28
   ....
29
\}}
29
\}}
30
  }
30
  }
-
 
31
  \item{exprObject}{alternative to \code{exprs} or \code{...}: a
-
 
32
    an \sQuote{expression-like} object, typically an
-
 
33
    \code{\link{expression}}, but also a \code{\link{call}}, a
-
 
34
    \code{\link{name}}, or atomic constant such as \code{TRUE}.
-
 
35
  }
31
  \item{local}{(only when \code{exprs} is used:) indicates the
36
  \item{local}{(only when \code{exprs} is used:) indicates the
32
    \code{\link{environment}} in which the expressions should be
37
    \code{\link{environment}} in which the expressions should be
33
    evaluated; by default the one where \code{stopifnot()} has been called from.}
38
    evaluated; by default the one where \code{stopifnot()} has been called from.}
34
}
39
}
35
\details{
40
\details{
Line 101... Line 106...
101
  2 < 2
106
  2 < 2
102
  all(1:10 < 12)
107
  all(1:10 < 12)
103
  "a" < "b"
108
  "a" < "b"
104
})
109
})
105
 
110
 
-
 
111
eObj <- expression(2 < 3, 3 <= 3:6, all(1:10 < 2))
-
 
112
stopifnot(exprObject = eObj)
-
 
113
stopifnot(exprObject = quote(3 == 3))
-
 
114
stopifnot(exprObject = TRUE)
-
 
115
 
-
 
116
 
106
# long all.equal() error messages are abbreviated:
117
# long all.equal() error messages are abbreviated:
107
stopifnot(all.equal(rep(list(pi),4), list(3.1, 3.14, 3.141, 3.1415)))
118
stopifnot(all.equal(rep(list(pi),4), list(3.1, 3.14, 3.141, 3.1415)))
108
 
119
 
109
options(op)  # revert to previous error handler
120
options(op)  # revert to previous error handler
110
}
121
}