Skip to content

Commit

Permalink
suppress echo of command for making .R
Browse files Browse the repository at this point in the history
remove tests of printf and replace them by tests of format and signif.


git-svn-id: https://svn.r-project.org/R/trunk@8158 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed Feb 14, 2000
1 parent 9be69ca commit 0e13901
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 111 deletions.
2 changes: 1 addition & 1 deletion tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Makedeps: Makefile
FORCE:

%.R : $(srcdir)/make-%.R stamp-R
$(R) < $< > /dev/null
@$(R) < $< > /dev/null

%.Rout : %.R
@rm -f $@ $@.fail
Expand Down
49 changes: 27 additions & 22 deletions tests/print-tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ v2 <- v1^(63/64)
v3 <- pi*100^(-1:3)
v4 <- (0:2)/1000 + 1e-10 #-- tougher one

digs1 <- c(1,2*(1:5),11:15) # 16: MS Windows differs
# 20: platform dependent
digs1 <- c(1,2*(1:5),11:15) # 16: platform dependent
# 30 gives ERROR : options(digits=30)
digs2 <- c(1:20)#,30) gives 'error' in R: ``print.default(): invalid digits..''

Expand Down Expand Up @@ -133,27 +132,33 @@ tx <- tx[is.finite(tx)] #-- all kept
(txp <- tx[tx >= 1])#-- Positive exponent -- 4 values
(txn <- tx[tx < 1])#-- Negative exponent -- 7 values

olddig <- options(digits=14) # RH6.0 fails at 15
z <- 1.234567891234567e27
for(dig in 1:14) cat(formatC(dig,w=2),
format(z, digits=dig), signif(z, digits=dig), "\n")
options(olddig)
# The following are tests of printf inside formatC
##------ Use Emacs screen width 134 ; Courier 12 ----
cat("dig| formatC(txp, d=dig)\n")
for(dig in 1:17)# about >= 18 is platform dependent [libc's printf()..].
cat(formatC(dig,w=2), formatC(txp, dig=dig, wid=-29),"\n")
cat("signif() behavior\n~~~~~~~~\n",
"dig| formatC(signif(txp, dig=dig), dig = dig\n")
for(dig in 1:15)#
cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig, wid=-26),"\n")

if(opt.conformance >= 1) {
noquote(cbind(formatC(txp, dig = 22)))
}

cat("dig| formatC(signif(txn, d = dig), dig=dig\n")
for(dig in 1:15)#
cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig, wid=-20),"\n")

##-- Testing 'print' / digits :
for(dig in 1:13) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!
cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+1)
}
# cat("dig| formatC(txp, d=dig)\n")
# for(dig in 1:17)# about >= 18 is platform dependent [libc's printf()..].
# cat(formatC(dig,w=2), formatC(txp, dig=dig, wid=-29),"\n")
# cat("signif() behavior\n~~~~~~~~\n",
# "dig| formatC(signif(txp, dig=dig), dig = dig\n")
# for(dig in 1:15)#
# cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig, wid=-26),"\n")

# if(opt.conformance >= 1) {
# noquote(cbind(formatC(txp, dig = 22)))
# }

# cat("dig| formatC(signif(txn, d = dig), dig=dig\n")
# for(dig in 1:15)#
# cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig, wid=-20),"\n")

# ##-- Testing 'print' / digits :
# for(dig in 1:13) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!
# cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+1)
# }

##-- Wrong alignment when printing character matrices with quote = FALSE
m1 <- matrix(letters[1:24],6,4)
Expand Down
130 changes: 42 additions & 88 deletions tests/print-tests.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R : Copyright 2000, The R Development Core Team
Version 1.0.0 Under development (unstable) (February 11, 2000)
Version 1.0.0 Under development (unstable) (February 14, 2000)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Expand Down Expand Up @@ -40,8 +40,7 @@ Type "q()" to quit R.
> v3 <- pi*100^(-1:3)
> v4 <- (0:2)/1000 + 1e-10 #-- tougher one
>
> digs1 <- c(1,2*(1:5),11:15) # 16: MS Windows differs
> # 20: platform dependent
> digs1 <- c(1,2*(1:5),11:15) # 16: platform dependent
> # 30 gives ERROR : options(digits=30)
> digs2 <- c(1:20)#,30) gives 'error' in R: ``print.default(): invalid digits..''
>
Expand Down Expand Up @@ -272,92 +271,47 @@ Type "q()" to quit R.
> (txn <- tx[tx < 1])#-- Negative exponent -- 7 values
[1] 2.002566e-308 2.222849e-308 2.225074e-308 2.225074e-308 2.225074e-308 2.227299e-308 2.447581e-308
>
> olddig <- options(digits=14) # RH6.0 fails at 15
> z <- 1.234567891234567e27
> for(dig in 1:14) cat(formatC(dig,w=2),
+ format(z, digits=dig), signif(z, digits=dig), "\n")
1 1e+27 1e+27
2 1.2e+27 1.2e+27
3 1.23e+27 1.23e+27
4 1.235e+27 1.235e+27
5 1.2346e+27 1.2346e+27
6 1.23457e+27 1.23457e+27
7 1.234568e+27 1.234568e+27
8 1.2345679e+27 1.2345679e+27
9 1.23456789e+27 1.23456789e+27
10 1.234567891e+27 1.234567891e+27
11 1.2345678912e+27 1.2345678912e+27
12 1.23456789123e+27 1.23456789123e+27
13 1.234567891235e+27 1.234567891235e+27
14 1.2345678912346e+27 1.2345678912346e+27
> options(olddig)
> # The following are tests of printf inside formatC
> ##------ Use Emacs screen width 134 ; Courier 12 ----
> cat("dig| formatC(txp, d=dig)\n")
dig| formatC(txp, d=dig)
> for(dig in 1:17)# about >= 18 is platform dependent [libc's printf()..].
+ cat(formatC(dig,w=2), formatC(txp, dig=dig, wid=-29),"\n")
1 2e+308 2e+308 2e+308 2e+308
2 1.6e+308 1.8e+308 1.8e+308 1.8e+308
3 1.62e+308 1.8e+308 1.8e+308 1.8e+308
4 1.618e+308 1.796e+308 1.798e+308 1.798e+308
5 1.6179e+308 1.7959e+308 1.7977e+308 1.7977e+308
6 1.61792e+308 1.7959e+308 1.79769e+308 1.79769e+308
7 1.617924e+308 1.795895e+308 1.797693e+308 1.797693e+308
8 1.6179238e+308 1.7958954e+308 1.797693e+308 1.7976931e+308
9 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+308
10 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693135e+308
11 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931349e+308
12 1.61792382138e+308 1.79589544173e+308 1.79769295509e+308 1.79769313486e+308
13 1.617923821376e+308 1.795895441727e+308 1.797692955093e+308 1.797693134862e+308
14 1.6179238213761e+308 1.7958954417275e+308 1.797692955093e+308 1.7976931348623e+308
15 1.61792382137608e+308 1.79589544172745e+308 1.797692955093e+308 1.79769313486232e+308
16 1.617923821376084e+308 1.795895441727453e+308 1.797692955093002e+308 1.797693134862316e+308
17 1.6179238213760842e+308 1.7958954417274534e+308 1.7976929550930023e+308 1.7976931348623157e+308
> cat("signif() behavior\n~~~~~~~~\n",
+ "dig| formatC(signif(txp, dig=dig), dig = dig\n")
signif() behavior
~~~~~~~~
dig| formatC(signif(txp, dig=dig), dig = dig
> for(dig in 1:15)#
+ cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig, wid=-26),"\n")
1 1e+308 1e+308 1e+308 1e+308
2 1.6e+308 1.7e+308 1.7e+308 1.7e+308
3 1.62e+308 1.79e+308 1.79e+308 1.79e+308
4 1.618e+308 1.796e+308 1.797e+308 1.797e+308
5 1.6179e+308 1.7959e+308 1.7976e+308 1.7976e+308
6 1.61792e+308 1.7959e+308 1.79769e+308 1.79769e+308
7 1.617924e+308 1.795895e+308 1.797692e+308 1.797693e+308
8 1.6179238e+308 1.7958954e+308 1.797693e+308 1.7976931e+308
9 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+308
10 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693134e+308
11 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931348e+308
12 1.61792382138e+308 1.79589544173e+308 1.79769295509e+308 1.79769313486e+308
13 1.617923821376e+308 1.795895441728e+308 1.797692955093e+308 1.797693134862e+308
14 1.617923821376e+308 1.7958954417274e+308 1.797692955093e+308 1.7976931348622e+308
15 1.61792382137609e+308 1.79589544172745e+308 1.797692955093e+308 1.79769313486231e+308
>
> if(opt.conformance >= 1) {
+ noquote(cbind(formatC(txp, dig = 22)))
+ }
>
> cat("dig| formatC(signif(txn, d = dig), dig=dig\n")
dig| formatC(signif(txn, d = dig), dig=dig
> for(dig in 1:15)#
+ cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig, wid=-20),"\n")
1 2e-308 2e-308 2e-308 2e-308 2e-308 2e-308 2e-308
2 2e-308 2.2e-308 2.2e-308 2.2e-308 2.2e-308 2.2e-308 2.4e-308
3 2e-308 2.22e-308 2.23e-308 2.23e-308 2.23e-308 2.23e-308 2.45e-308
4 2.003e-308 2.223e-308 2.225e-308 2.225e-308 2.225e-308 2.227e-308 2.448e-308
5 2.0026e-308 2.2228e-308 2.2251e-308 2.2251e-308 2.2251e-308 2.2273e-308 2.4476e-308
6 2.00257e-308 2.22285e-308 2.22507e-308 2.22507e-308 2.22507e-308 2.2273e-308 2.44758e-308
7 2.002566e-308 2.222849e-308 2.225074e-308 2.225074e-308 2.225074e-308 2.227299e-308 2.447581e-308
8 2.0025665e-308 2.2228488e-308 2.2250736e-308 2.2250739e-308 2.2250741e-308 2.2272989e-308 2.4475812e-308
9 2.00256647e-308 2.22284878e-308 2.22507364e-308 2.22507386e-308 2.22507408e-308 2.22729893e-308 2.44758124e-308
10 2.002566473e-308 2.222848785e-308 2.225073636e-308 2.225073859e-308 2.225074081e-308 2.227298932e-308 2.447581244e-308
11 2.0025664727e-308 2.2228487846e-308 2.225073636e-308 2.2250738585e-308 2.225074081e-308 2.2272989324e-308 2.4475812444e-308
12 2.00256647266e-308 2.22284878465e-308 2.225073636e-308 2.22507385851e-308 2.22507408101e-308 2.22729893237e-308 2.44758124436e-308
13 2.002566472656e-308 2.222848784649e-308 2.225073636e-308 2.225073858507e-308 2.225074081015e-308 2.227298932366e-308 2.447581244358e-308
14 2.0025664726565e-308 2.2228487846487e-308 2.2250736359998e-308 2.2250738585072e-308 2.2250740810146e-308 2.2272989323657e-308 2.4475812443579e-308
15 2.00256647265648e-308 2.2228487846487e-308 2.22507363599982e-308 2.2250738585072e-308 2.22507408101459e-308 2.22729893236571e-308 2.44758124435792e-308
>
> ##-- Testing 'print' / digits :
> for(dig in 1:13) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!
+ cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+1)
+ }
dig= 1 : [1] 1e+308 1e+308 1e+308 1e+308
dig= 2 : [1] 1.6e+308 1.7e+308 1.7e+308 1.7e+308
dig= 3 : [1] 1.62e+308 1.79e+308 1.79e+308 1.79e+308
dig= 4 : [1] 1.618e+308 1.796e+308 1.797e+308 1.797e+308
dig= 5 : [1] 1.6179e+308 1.7959e+308 1.7976e+308 1.7976e+308
dig= 6 : [1] 1.61792e+308 1.79590e+308 1.79769e+308 1.79769e+308
dig= 7 : [1] 1.617924e+308 1.795895e+308 1.797692e+308 1.797693e+308
dig= 8 : [1] 1.6179238e+308 1.7958954e+308 1.7976930e+308 1.7976931e+308
dig= 9 : [1] 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+308
dig= 10 : [1] 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693134e+308
dig= 11 : [1] 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931348e+308
dig= 12 : [1] 1.61792382138e+308 1.79589544173e+308 1.79769295509e+308 1.79769313486e+308
dig= 13 : [1] 1.6179238213759e+308 1.7958954417279e+308 1.7976929550929e+308 1.7976931348619e+308
> # cat("dig| formatC(txp, d=dig)\n")
> # for(dig in 1:17)# about >= 18 is platform dependent [libc's printf()..].
> # cat(formatC(dig,w=2), formatC(txp, dig=dig, wid=-29),"\n")
> # cat("signif() behavior\n~~~~~~~~\n",
> # "dig| formatC(signif(txp, dig=dig), dig = dig\n")
> # for(dig in 1:15)#
> # cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig, wid=-26),"\n")
>
> # if(opt.conformance >= 1) {
> # noquote(cbind(formatC(txp, dig = 22)))
> # }
>
> # cat("dig| formatC(signif(txn, d = dig), dig=dig\n")
> # for(dig in 1:15)#
> # cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig, wid=-20),"\n")
>
> # ##-- Testing 'print' / digits :
> # for(dig in 1:13) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!
> # cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+1)
> # }
>
> ##-- Wrong alignment when printing character matrices with quote = FALSE
> m1 <- matrix(letters[1:24],6,4)
Expand Down

0 comments on commit 0e13901

Please sign in to comment.