Skip to content

Conversation

@eddelbuettel
Copy link
Member

This PR updates #nocov tags for a number of R and C++ source files. Apart from one remaining 'function factory' function that confuses the coverage counting, this pushes the needle towards full coverage.

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

Copy link
Member

@Enchufa2 Enchufa2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments below.

// This is used internally instead of Rf_eval() to make evaluation safer
inline SEXP Rcpp_eval_impl(SEXP expr, SEXP env) {
return Rcpp_fast_eval(expr, env);
inline SEXP Rcpp_eval_impl(SEXP expr, SEXP env) { // #nocov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we drop this and use Rcpp_fast_eval directly in the remaining spots?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted. And when you step back and look at that file you see this in a 'else' branch we no longer need (as we're always greater or equal R 3.5.0 now) and with it the whole UNWIND_PROTECT define can likely go away. I had been meaning to ping you about that. Cleanup for the next release cycle?


/* check if we can use a fast version */
if( TYPEOF(x) == STRSXP && parent.size() == Rf_length(x) ){
if( TYPEOF(x) == STRSXP && parent.size() == Rf_length(x) ){ // #nocov start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should design a test to check the other side of the branch instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, just about every instance of #nocov could deserve a test. Some of this areas have been without one for twelve or more years though. Adding tests is always the hope, in practice it does not happen all that much.

try{
index = parent.offset(name) ;
parent[ index ] = rhs ;
parent[ index ] = rhs ; // #nocov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird. Does this mean that we don't have any test that doesn't throw here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. That is indeed one of the weirder ones.

/* We need to evaluate if it is a promise */
if( TYPEOF(res) == PROMSXP){
res = internal::Rcpp_eval_impl( res, env ) ;
res = internal::Rcpp_eval_impl( res, env ) ; // #nocov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is important enough to test it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. PRs always welcome. Or if you want to add a quick test now we can use this PR.

typedef XPtr<class_Base> XP_Class ;
typedef Rcpp::XPtr<Rcpp::Module> XP ;
CppClass( SEXP x) : S4(x){};
CppClass( SEXP x) : S4(x){}; // #nocov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should test instantiation from SEXP?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants