Skip to content

Commit 7648542

Browse files
committed
Merge branch 'RMemberListTrialSimplify2019'
* RMemberListTrialSimplify2019: ENH R abstract_access_runme ENH R accessor processing test Removed some remaining commented sections moved registration routine and use swig_name_get calling Swig_name_setget Used Swig_name_register so that Swig_name_wrapper produces the correct name without a separate replace call. Removed last instance of using Strcmp to check for a set/get method. Replaced with check for flag. Alternative version of using memberlist processing. This clarifies the logic within OutputMemberReferenceMethod by filtering the lists into classes, rather than doing it internally. Code isn't any shorter. commenting out unused code first pass at removing string comparisons for set/get methods trial changing member list processing
2 parents 7405bd6 + 25a9e35 commit 7648542

File tree

2 files changed

+223
-100
lines changed

2 files changed

+223
-100
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
clargs <- commandArgs(trailing=TRUE)
2+
source(file.path(clargs[1], "unittest.R"))
3+
4+
dyn.load(paste("abstract_access", .Platform$dynlib.ext, sep=""))
5+
source("abstract_access.R")
6+
7+
dd <- D()
8+
unittest(1, dd$z())
9+
unittest(1, dd$do_x())
10+
11+
## Original version allowed dd$z <- 2
12+
tryCatch({
13+
dd$z <- 2
14+
# force an error if the previous line doesn't raise an exception
15+
stop("Test Failure A")
16+
}, error = function(e) {
17+
if (e$message == "Test Failure A") {
18+
# Raise the error again to cause a failed test
19+
stop(e)
20+
}
21+
message("Correct - no dollar assignment method found")
22+
}
23+
)
24+
25+
tryCatch({
26+
dd[["z"]] <- 2
27+
# force an error if the previous line doesn't raise an exception
28+
stop("Test Failure B")
29+
}, error = function(e) {
30+
if (e$message == "Test Failure B") {
31+
# Raise the error again to cause a failed test
32+
stop(e)
33+
}
34+
message("Correct - no dollar assignment method found")
35+
}
36+
)
37+
38+
## The methods are attached to the parent class - see if we can get
39+
## them
40+
tryCatch({
41+
m1 <- getMethod('$', "_p_A")
42+
}, error = function(e) {
43+
stop("No $ method found - there should be one")
44+
}
45+
)
46+
47+
## These methods should not be present
48+
## They correspond to the tests that are expected
49+
## to fail above.
50+
tryCatch({
51+
m2 <- getMethod('$<-', "_p_A")
52+
# force an error if the previous line doesn't raise an exception
53+
stop("Test Failure C")
54+
}, error = function(e) {
55+
if (e$message == "Test Failure C") {
56+
# Raise the error again to cause a failed test
57+
stop(e)
58+
}
59+
message("Correct - no dollar assignment method found")
60+
}
61+
)
62+
63+
tryCatch({
64+
m3 <- getMethod('[[<-', "_p_A")
65+
# force an error if the previous line doesn't raise an exception
66+
stop("Test Failure D")
67+
}, error = function(e) {
68+
if (e$message == "Test Failure D") {
69+
# Raise the error again to cause a failed test
70+
stop(e)
71+
}
72+
message("Correct - no list assignment method found")
73+
}
74+
)

0 commit comments

Comments
 (0)