brodieG / unitizer

Easy R Unit Tests
Other
39 stars 7 forks source link

More Comprehensive State Integrity Checking #209

Open brodieG opened 7 years ago

brodieG commented 7 years ago

Related to #197, it would be good to confirm that all the values in unitizer@items.ref[[i]]@glob.indices actually map to a value in unitizer@state.ref when unitizers are stored and loaded. There is some dummy code commented out in R/load.R load() as of 812212b that does this, also copied here:

    # # check for and normalize state issues; this came up as a result of #197
    # # where our state objects were corrupted; really this should be handled
    # # in a more systematic way like we do for broader validation; if this
    # # happens more often we can look into that;
    # # NOTE: figured out what was going on here so commenting this out for now

    # ref.indices <- do.call(
    #   cbind,
    #   lapply(
    #     unitizers[[i]]@items.ref,
    #     function(z) as.integer(slot(z, "glob.indices"))
    #   )
    # )
    # ref.state <- lapply(
    #   slotNames(unitizers[[i]]@state.ref),
    #   function(z) length(slot(unitizers[[i]]@state.ref, z))
    # )
    # if(!identical(names(ref.state), names(ref.indices)))
    #   stop(
    #     "Internal error: incompatible global index structure; ",
    #     "contact maintainer"
    #   )

    # if(
    #   any(
    #     unlist(
    #       Map(
    #         function(v, w) any(v > w),
    #         split(ref.indices, row(ref.indices), ref.state), ref.state
    #   ) ) )
    # ) {
    #   meta_word_msg(
    #     "Unitizer ", i, " has corrupted state indices, we are resetting ",
    #     "them to NULL, which means review of reference tests will not ",
    #     "correctly reflect the reference states.  This is not expected ",
    #     "behavior and you should contact maintainer if it persists.", sep=""
    #   )
    #   glob.ind.def <- new("unitizerGlobalIndices")
    #   for(j in seq_along(unitizers[[i]]@items.ref))
    #     unitizers[[i]]@items.ref[[j]]@glob.indices <- glob.ind.def
    # }