The R Project SVN R

Rev

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

Rev 63146 Rev 63173
Line 1... Line 1...
1
 
1
 
2
R Under development (unstable) (2013-07-02 r63144) -- "Unsuffered Consequences"
2
R Under development (unstable) (2013-07-04 r63172) -- "Unsuffered Consequences"
3
Copyright (C) 2013 The R Foundation for Statistical Computing
3
Copyright (C) 2013 The R Foundation for Statistical Computing
4
Platform: x86_64-unknown-linux-gnu (64-bit)
4
Platform: x86_64-unknown-linux-gnu (64-bit)
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
Line 98... Line 98...
98
[1] "* "
98
[1] "* "
99
 
99
 
100
$enumFormat
100
$enumFormat
101
function (n) 
101
function (n) 
102
sprintf("%d. ", n)
102
sprintf("%d. ", n)
103
<environment: 0x28b2180>
103
<environment: 0x2853b10>
104
 
104
 
105
$showURLs
105
$showURLs
106
[1] FALSE
106
[1] FALSE
107
 
107
 
108
$code_quote
108
$code_quote
Line 132... Line 132...
132
[1] "* "
132
[1] "* "
133
 
133
 
134
$enumFormat
134
$enumFormat
135
function (n) 
135
function (n) 
136
sprintf("%d. ", n)
136
sprintf("%d. ", n)
137
<environment: 0x28b2180>
137
<environment: 0x2853b10>
138
 
138
 
139
$showURLs
139
$showURLs
140
[1] FALSE
140
[1] FALSE
141
 
141
 
142
$code_quote
142
$code_quote
Line 166... Line 166...
166
[1] "* "
166
[1] "* "
167
 
167
 
168
$enumFormat
168
$enumFormat
169
function (n) 
169
function (n) 
170
sprintf("%d. ", n)
170
sprintf("%d. ", n)
171
<environment: 0x28b2180>
171
<environment: 0x2853b10>
172
 
172
 
173
$showURLs
173
$showURLs
174
[1] FALSE
174
[1] FALSE
175
 
175
 
176
$code_quote
176
$code_quote
Line 216... Line 216...
216
  Failed to get expected warning in evaluating sqrt(2)
216
  Failed to get expected warning in evaluating sqrt(2)
217
> ## .. Failed to get expected warning in evaluating sqrt(2)
217
> ## .. Failed to get expected warning in evaluating sqrt(2)
218
>      assertCondition(sqrt("abc"), "error")   # ok
218
>      assertCondition(sqrt("abc"), "error")   # ok
219
> try( assertCondition(sqrt("abc"), "warning") )# -> error: had no warning
219
> try( assertCondition(sqrt("abc"), "warning") )# -> error: had no warning
220
Error in assertCondition(sqrt("abc"), "warning") : 
220
Error in assertCondition(sqrt("abc"), "warning") : 
221
  Expected warning, got simpleError in evaluating sqrt("abc")
221
  Got simpleError (non-numeric argument to mathematical function) in evaluating sqrt("abc"); expected warning
222
> ## verbose ==> show error message additionally:
222
> ## verbose ==> show error message additionally:
223
>      assertCondition(sqrt("abc"), verbose=TRUE, "error")
223
>      assertCondition(sqrt("abc"), verbose=TRUE, "error")
224
Asserted error: non-numeric argument to mathematical function
224
Asserted error : non-numeric argument to mathematical function
225
> 
225
> 
226
> assertCondition(matrix(1:5, 2,3), "warning")
226
> assertCondition(matrix(1:5, 2,3), "warning")
227
> try( assertCondition(matrix(1:8, 4,3), "error") )
227
> try( assertCondition(matrix(1:8, 4,3), "error") )
228
Warning in matrix(1:8, 4, 3) :
-
 
229
  data length [8] is not a sub-multiple or multiple of the number of columns [3]
-
 
230
Error in assertCondition(matrix(1:8, 4, 3), "error") : 
228
Error in assertCondition(matrix(1:8, 4, 3), "error") : 
231
  Failed to get expected error in evaluating matrix(1:8, 4, 3)
229
  Got simpleWarning (data length [8] is not a sub-multiple or multiple of the number of columns [3]) in evaluating matrix(1:8, 4, 3); expected error
232
> ## .. Failed to get expected error ....
230
> ## .. Failed to get expected error ....
233
> 
231
> 
234
> ## either warning or worse:
232
> ## either warning or worse:
235
> assertCondition(matrix(1:8, 4,3), verbose=TRUE, "error","warning") # OK
233
> assertCondition(matrix(1:8, 4,3), verbose=TRUE, "error","warning") # OK
236
Asserted warning: data length [8] is not a sub-multiple or multiple of the number of columns [3]
234
Asserted warning : data length [8] is not a sub-multiple or multiple of the number of columns [3]
237
> assertCondition(matrix(1:8, 4, 3), "warning", "error") # ditto
235
> assertCondition(matrix(1:8, 4, 3), "warning", "error") # ditto
238
> 
236
> 
239
> ## when both are signalled:
237
> ## when both are signalled:
240
> ff <- function() { warning("my warning"); stop("my error") }
238
> ff <- function() { warning("my warning"); stop("my error") }
241
>     assertCondition(ff(), "warning")
239
>     assertCondition(ff(), "warning")
242
>     assertCondition(ff(), "error")          # ok + signalling the warning
240
>     assertCondition(ff(), "error")          # ok
243
Warning in ff() : my warning
-
 
244
>     assertCondition(ff(), "error", ignoreWarning=TRUE)   # ditto
-
 
245
Warning in ff() : my warning
-
 
246
> try(assertCondition(ff(), "error", ignoreWarning=FALSE) )# not ok:
-
 
247
Error in assertCondition(ff(), "error", ignoreWarning = FALSE) : 
-
 
248
  Expected error, got simpleWarning in evaluating ff()
-
 
249
>                                           #-> gets warning instead of error
-
 
250
> assertCondition(ff(), "error", "warning") # ok (quietly, catching warning)
241
> assertCondition(ff(), "error", "warning") # ok (quietly, catching warning)
251
> 
242
> 
-
 
243
> ## assert that assertC..() does not assert [and use *one* argument only]
-
 
244
> assertCondition( assertCondition(sqrt( 2   ), "warning") )
-
 
245
> assertCondition( assertCondition(sqrt("abc"), "warning"), "error")
-
 
246
> assertCondition( assertCondition(matrix(1:8, 4,3), "error"),
-
 
247
+                 "error", verbose=TRUE)
-
 
248
Asserted error : Got simpleWarning (data length [8] is not a sub-multiple or multiple of the number of columns [3]) in evaluating matrix(1:8, 4, 3); expected error
-
 
249
> 
252
> 
250
> 
253
> 
251
> 
254
> cleanEx()
252
> cleanEx()
255
> nameEx("bibstyle")
253
> nameEx("bibstyle")
256
> ### * bibstyle
254
> ### * bibstyle
Line 285... Line 283...
285
+     pages = "211-252"))
283
+     pages = "211-252"))
286
> 
284
> 
287
> bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
285
> bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
288
+     fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
286
+     fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
289
+        .init = TRUE)
287
+        .init = TRUE)
290
<environment: 0x2d782a8>
288
<environment: 0x2d8adf8>
291
> print(refs, .bibstyle = "unsorted")
289
> print(refs, .bibstyle = "unsorted")
292
[1] R Core Team (2013). _R: A Language and Environment for Statistical
290
[1] R Core Team (2013). _R: A Language and Environment for Statistical
293
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
291
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
294
<URL: http://www.R-project.org>.
292
<URL: http://www.R-project.org>.
295
 
293
 
Line 1033... Line 1031...
1033
> 
1031
> 
1034
> ### * <FOOTER>
1032
> ### * <FOOTER>
1035
> ###
1033
> ###
1036
> options(digits = 7L)
1034
> options(digits = 7L)
1037
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
1035
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
1038
Time elapsed:  0.476 0.034 0.6 0 0 
1036
Time elapsed:  0.474 0.026 0.639 0 0 
1039
> grDevices::dev.off()
1037
> grDevices::dev.off()
1040
null device 
1038
null device 
1041
          1 
1039
          1 
1042
> ###
1040
> ###
1043
> ### Local variables: ***
1041
> ### Local variables: ***