Showing 42 of 99 files from the diff.
Other files ignored by Codecov
man/unitize.Rd has changed.
R/class_unions.R has changed.
man/demo.Rd has changed.
man/text_wrap.Rd has changed.
tests/runtt.R has changed.
DESCRIPTION has changed.
NEWS.md has changed.
tests/aunitizer.R has changed.
CRAN.md has changed.

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Returns a Character Function Name From A Language Object
2 18
#
3 19
# Note this doesn't really try to check too hard whether the \code{`x`} is

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
#' @include item.sub.R
3 19
#' @include unitizer.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Alter Older unitizer Versions So They Pass Validation in Latest Version
2 18
#
3 19
# Sequentially applies all applicable patches

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Emulate the R Console Prompt
2 18
#
3 19
# @keywords internal

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# - Required Code -------------------------------------------------------------
2 18
3 19
#' @include conditions.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Convert a \code{testthat} Test File to a \code{unitizer}
2 18
#'
3 19
#' Converts a \bold{copy} of an existing \code{testthat} test file to a

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include list.R
2 18
#' @include class_unions.R
3 19
#' @include section.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
#' @include item.sub.R
3 19
#' @include section.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
## Display helper function
2 18
##
3 19
## @keywords internal

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include class_unions.R
2 18
3 19
NULL

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Unitize an R Test Script
2 18
#'
3 19
#' Turn standard R scripts into unit tests by storing the expressions therein
@@ -14,7 +30,8 @@
Loading
14 30
#' name and location, but you can specify your own location as an id, or even
15 31
#' use a completely different mechanism to store the \code{unitizer} data by
16 32
#' implementing S3 methods for \code{\link{get_unitizer}} and
17 -
#' \code{\link{set_unitizer}}.
33 +
#' \code{\link{set_unitizer}}.  For more details about storage see those
34 +
#' functions.
18 35
#'
19 36
#' \code{review} allows you to review existing \code{unitizer}s and modify them
20 37
#' by dropping tests from them.  Tests are not evaluated in this mode; you are
@@ -63,12 +80,12 @@
Loading
63 80
#'     mechanisms for the \code{unitizers} (see \code{\link{get_unitizer}})
64 81
#' }
65 82
#' @param state character(1L) one of
66 -
#'   \code{c("prisitine", "default", "basic", "off", "safe")}, an environment,
67 -
#'   or a state object produced by \code{\link{state}} or \code{\link{in_pkg}};
68 -
#'   modifies how \code{unitizer} manages aspects of session state that could
69 -
#'   affect test evaluation, including the parent evaluation environment.  For
70 -
#'   more details see \code{\link{unitizerState}} documentation and
71 -
#'   \code{vignette("unitizer_reproducible_tests")}
83 +
#'   \code{c("prisitine", "recommended", "basic", "off", "safe")}, an
84 +
#'   environment, or a state object produced by \code{\link{state}} or
85 +
#'   \code{\link{in_pkg}}; modifies how \code{unitizer} manages aspects of
86 +
#'   session state that could affect test evaluation, including the parent
87 +
#'   evaluation environment.  For more details see \code{\link{unitizerState}}
88 +
#'   documentation and \code{vignette("unitizer_reproducible_tests")}
72 89
#' @param pre NULL, or a character vector pointing to files and/or directories.
73 90
#'   If a character vector, then any files referenced therein will be sourced,
74 91
#'   and any directories referenced therein will be scanned non-recursively for

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Summary of Changes
2 18
#'
3 19
#' Changes arise any time a user, through the interactive unitizer mode,

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include options.R
2 18
#' @include global.R
3 19

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
#' @include item.sub.R
3 19
#' @include class_unions.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include unitizer.R
2 18
3 19
NULL

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include unitizer.R
2 18
#' @include conditions.R
3 19
#' @include browse.struct.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include class_unions.R
2 18
3 19
NULL
@@ -98,7 +114,7 @@
Loading
98 114
  res
99 115
}
100 116
compress_ns_data <- function(x) {
101 -
  vapply(x, function(y) sprintf("%s (v%s", y$name, y$version), character(1L))
117 +
  vapply(x, function(y) sprintf("%s (v%s", y$names, y$version), character(1L))
102 118
}
103 119
# Search Path Management Functions
104 120
#
@@ -666,7 +682,7 @@
Loading
666 682
        try(path.package(sub("^package:(.*)", "\\1", x))) else ""
667 683
      ver <- try(getNamespaceVersion(x), silent=TRUE)
668 684
      list(
669 -
        name=x,
685 +
        names=x,
670 686
        lib.loc=if(!inherits(loc, "try-error")) loc else "",
671 687
        version=if(!inherits(ver, "try-error")) ver else ""
672 688
      )

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Text Representations of HTML Objects
2 18
#
3 19
# Functions defined here should ultimately be extended into a more

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include global.R
2 18
3 19
NULL
@@ -57,9 +73,13 @@
Loading
57 73
#'      tests.
58 74
#'   \item Random Seed: can be set to a specific value at the
59 75
#'     beginning of each test file so that tests using random values get the
60 -
#'     same value at every test iteration. If you change the order of  your
61 -
#'     tests, or add a test that uses a random sampling before the end of
62 -
#'     the file, that will still affect the random seed.
76 +
#'     same value at every test iteration. This only sets the seed at the
77 +
#'     beginning of each test file, so changes in order or number of functions
78 +
#'     that generate random numbers in your test file will affect subsequent
79 +
#'     tests.  The advantage of doing this over just setting the seed directly
80 +
#'     in the test files is that \code{unitizer} tracks the value of the seed
81 +
#'     and will tell you the seed changed for any given test (e.g. because you
82 +
#'     added a test in the middle of the file that uses the random seed).
63 83
#'   \item Working Directory: can be set to the tests directory
64 84
#'     inside the package directory if the test files appear to be inside the
65 85
#'     folder structure of a package.  This mimics R CMD check behavior.  If
@@ -71,18 +91,21 @@
Loading
71 91
#'     prior to running your tests.  If you want to use the same libraries
72 92
#'     across multiple tests you can load them with the \code{pre} argument to
73 93
#'     \code{\link{unitize}} or \code{\link{unitize_dir}}.
74 -
#'   \item Options: same as search path
94 +
#'   \item Options: same as search path, but see "Namespaces" next.
75 95
#'   \item Namespaces: same as search path; this
76 96
#'     option is only made available to support options since many namespaces
77 97
#'     set options \code{onLoad}, and as such it is necessary to unload and
78 -
#'     re-load them to ensure default options are set.
98 +
#'     re-load them to ensure default options are set.  See the "Namespaces and
99 +
#'     Options" section.
79 100
#' }
80 101
#'
81 -
#' In the \dQuote{recommended} state tracking, mode parent environment, random
82 -
#' seed, working directory, and search path are all managed.  For example, with
83 -
#' the search path managed, each test file will start evaluation with the search
84 -
#' path set to what you would find in a vanilla R session.  All these settings
85 -
#' are returned to their original values when \code{unitizer} exits.
102 +
#' In the \dQuote{recommended} state tracking mode, parent environment, random
103 +
#' seed, working directory, and search path are all managed to level 2, which
104 +
#' approximates what you would find in a fresh session (see "Custom Control"
105 +
#' section below).  For example, with the search path managed, each test file
106 +
#' will start evaluation with the search path set to the tests folder of your
107 +
#' package.  All these settings are returned to their original values when
108 +
#' \code{unitizer} exits.
86 109
#'
87 110
#' You can modify what aspects of state are managed by using the \code{state}
88 111
#' parameter to \code{\link{unitize}}.  If you are satisfied with basic default
@@ -105,7 +128,8 @@
Loading
105 128
#'   \item "recommended": \itemize{
106 129
#'       \item Use special (non \code{.GlobalEnv}) parent environemnt
107 130
#'       \item Manage search path
108 -
#'       \item Manage random seed
131 +
#'       \item Manage random seed (and set it to be of type "Wichmann-Hill"
132 +
#'         for space considerations).
109 133
#'       \item Manage workign directory
110 134
#'       \item Leave namespace and options untouched
111 135
#'     }
@@ -156,12 +180,17 @@
Loading
156 180
#'     \itemize{
157 181
#'       \item 0 turn off state tracking
158 182
#'       \item 1 track, but start with state as it was when \code{unitize} was
159 -
#'         called
183 +
#'         called.
160 184
#'       \item 2 track and set state to what you would typically find in a clean
161 185
#'         R session, with the exception of \code{random.seed}, which is
162 186
#'         set to \code{getOption("unitizer.seed")} (of kind "Wichmann-Hill"
163 187
#'         as that seed is substantially smaller than the R default seed).
164 188
#' } }
189 +
#'
190 +
#' If you chose to use level \code{1} for the random seed you should consider
191 +
#' picking a random seed type before you start unitizer that is small like
192 +
#' "Wichman-Hill" as the seed will be recorded each time it changes.
193 +
#'
165 194
#' @section Permanently Setting State Tracking:
166 195
#'
167 196
#' You can permanently change the default state by setting the
@@ -219,7 +248,7 @@
Loading
219 248
#' }
220 249
#' @param search.path one of \code{0:2}, uses the default value corresponding to
221 250
#'   \code{getOption(unitizer.state)}, which is 0 in the default unitizer state
222 -
#'   of \dQuote{off}.
251 +
#'   of \dQuote{off}.  See "Custom Control" section for details.
223 252
#' @param options same as \code{search.path}
224 253
#' @param working.directory same as \code{search.path}
225 254
#' @param random.seed same as \code{search.path}
@@ -364,7 +393,7 @@
Loading
364 393
      return(
365 394
        paste0(
366 395
          "Invalid state object, slots must be ",
367 -
          deparse(.unitizer.global.settings.names, width=500)
396 +
          deparse(.unitizer.global.settings.names, width.cutoff=500L)
368 397
      ) )
369 398
    }
370 399
    for(i in .unitizer.global.settings.names) {

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# - Required Code -------------------------------------------------------------
2 18
3 19
#' @include conditions.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include is.R
2 18
#' @include capture.R
3 19
@@ -42,7 +58,7 @@
Loading
42 58
    if(!identical(slotNames(object), .unitizer.global.settings.names)) {
43 59
      paste0(
44 60
        "Invalid global object, slots must be ",
45 -
        deparse(.unitizer.global.settings.names, width=500)
61 +
        deparse(.unitizer.global.settings.names, width.cutoff=500L)
46 62
      )
47 63
    TRUE
48 64
} )
@@ -273,7 +289,7 @@
Loading
273 289
      ver <- ns[[".__NAMESPACE__."]][["spec"]]["version"]
274 290
      if(is.null(ver)) ver <- ""
275 291
      if(is.null(loc)) loc <- ""
276 -
      list(name=x, lib.loc=loc, version=ver)
292 +
      list(names=x, lib.loc=loc, version=ver)
277 293
    },
278 294
    simplify=FALSE
279 295
  )

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
3 19
NULL

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include class_unions.R
2 18
#' @include global.R
3 19

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include unitizer.R
2 18
3 19
NULL

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Generates a Dummy Item For Use in Examples
2 18
#'
3 19
#' The only purpose of this function is to create a \code{unitizerItem} for use
@@ -111,7 +127,7 @@
Loading
111 127
    cond.len <- min(length(target), length(current))
112 128
113 129
    res <- lapply(
114 -
      seq(len=cond.len), function(x) all.equal(target[[x]], current[[x]])
130 +
      seq(length.out=cond.len), function(x) all.equal(target[[x]], current[[x]])
115 131
    )
116 132
    errs <- which(vapply(res, Negate(isTRUE), logical(1L)))
117 133
    if(!(err.len <- length(errs))) {

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# This used to have all the state comparison methods, but those just became
2 18
# unneeded with the advent of diffobj
3 19
#

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
## Helper Functions to Capture and Process stdout/err Output
2 18
##
3 19
## \code{set} functions set sinks, and \code{get} functions retrieve the

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Demo Details and Helper Functions
2 18
#'
3 19
#' \code{unitizer} provides an interactive demo you can run with

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Runs The Basic Stuff
2 18
#
3 19
# Used by both \code{\link{unitize}} and \code{\link{review}}
@@ -525,7 +541,7 @@
Loading
525 541
  # Loop through all unitizers, evaluating the ones that have been marked with
526 542
  # the `eval` slot for evaluation, and resetting that slot to FALSE
527 543
528 -
  for(i in seq(length=test.len)) {
544 +
  for(i in seq(length.out=test.len)) {
529 545
    test.dat <- tests.parsed[[i]]
530 546
    unitizer <- unitizers[[i]]
531 547
@@ -946,7 +962,13 @@
Loading
946 962
        function(x)
947 963
          is.symbol(x[[1]]) &&
948 964
          as.character(x[[1]]) %in%
949 -
          c("withCallingHandlers", "withRestarts", "tryCatch")
965 +
          c(
966 +
            "withCallingHandlers",
967 +
            # testthat added a restart in 80a81fd (2.3.1 or 2.3.0), so need
968 +
            # a way of ignoring this for tests unitizer tests.
969 +
            if(!isTRUE(getOption('unitizer.restarts.ok'))) "withRestarts",
970 +
            "tryCatch"
971 +
          )
950 972
    ) )
951 973
  )
952 974
    warning(

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
setMethod(
2 18
  "diffObj", c("conditionList", "conditionList"),
3 19
  function(target, current, ...) {

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Set and Retrieve Store Contents
2 18
#'
3 19
#' These functions are not used directly; rather, they are used by
@@ -7,7 +23,12 @@
Loading
7 23
#' objects.
8 24
#'
9 25
#' By default, only a character method is defined, which will interpret
10 -
#' its inputs as a filesystem path.
26 +
#' its inputs as a filesystem path to the \code{unitizer} folder.  RDSes of
27 +
#' serialization type 2 will be stored and retrieved from there.  The
28 +
#' serialization format may change in the future, but if R maintains
29 +
#' facilities to read/write type 2, we will provide the option to use
30 +
#' that format.  At this time there is no API to change the serialization
31 +
#' format.
11 32
#'
12 33
#' You may write your own methods for special storage situations (
13 34
#' e.g SQL database, ftp server, etc) with the understanding that the
@@ -55,6 +76,7 @@
Loading
55 76
#' }
56 77
#'
57 78
#' @aliases get_unitizer
79 +
#' @seealso \code{\link{saveRDS}}
58 80
#' @export
59 81
#' @param store.id a filesystem path to the store (an .rds file)
60 82
#' @param unitizer a \code{unitizer-class} object containing the store
@@ -98,7 +120,13 @@
Loading
98 120
  } else if (!file_test("-d", store.id)) {
99 121
    stop("'", store.id, "' is not a directory.")
100 122
  }
101 -
  if(inherits(try(saveRDS(unitizer, paste0(store.id, "/data.rds"))), "try-error")) {
123 +
  if(
124 +
    inherits(
125 +
      try(
126 +
        saveRDS(unitizer, paste0(store.id, "/data.rds"), version=2)), 
127 +
        "try-error"
128 +
      )
129 +
    ) {
102 130
    stop("Failed setting unitizer; see prior error messages for details.")
103 131
  }
104 132
  TRUE

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
3 19
NULL
@@ -72,7 +88,7 @@
Loading
72 88
73 89
sizeRDS <- function(object) {
74 90
  f <- tempfile()
75 -
  if(inherits(try(saveRDS(object, f)), "try-error")) return(NA)
91 +
  if(inherits(try(saveRDS(object, f, version=2)), "try-error")) return(NA)
76 92
  size <- file.info(f)$size
77 93
  unlink(f)
78 94
  size

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include search.R
2 18
3 19
NULL
@@ -134,6 +150,9 @@
Loading
134 150
#'     before quitting; this is to avoid accidentally quitting after running a
135 151
#'     \code{unitizer} with many slow running tests and having to re-run them
136 152
#'     again.
153 +
#'   \item \code{unitizer.restarts.ok} TRUE or FALSE, suppresses warnings when
154 +
#'     running inside a `withRestarts` block, which is normally a warning.
155 +
#'     Needed due to `test_that` adding a `withRestart`
137 156
#' }
138 157
#'
139 158
#' @name unitizer.opts
@@ -300,7 +319,10 @@
Loading
300 319
  # random seed to use by default, "Wichman-Hill" because default seed is large
301 320
  unitizer.seed= list(seed=42L, kind="Wichmann-Hill"),
302 321
  unitizer.max.env.depth=20000L,
303 -
  unitizer.use.diff=TRUE
322 +
  unitizer.use.diff=TRUE,
323 +
  # whether to warn if `unitizer` is run in `withRestarts` context, added b/c
324 +
  # testthat added a restart in 80a81fd
325 +
  unitizer.restarts.ok=FALSE
304 326
)
305 327
306 328
#' Checks that options meet expectations before anything gets run

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' Edit Calls In Unitizer
2 18
#'
3 19
#' Used if you want to change language in test expression in a unitizer when

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
#' @include item.sub.R
3 19
#' @include unitizer.R

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include item.R
2 18
#' @include unitizer.R
3 19
#' @include class_unions.R
@@ -649,8 +665,9 @@
Loading
649 665
650 666
    mapping.new <- new("unitizerBrowseMapping",
651 667
      # This id tracks the order of tests as we intend to review them
668 +
      # is it possible for sum(item.count) to be zero?
652 669
      item.id=(max.item + 1L):(max.item + sum(item.count)),
653 -
      item.id.rel=unlist(lapply(item.count, function(x) seq(len=x))),
670 +
      item.id.rel=unlist(lapply(item.count, function(x) seq(length.out=x))),
654 671
      item.id.orig=vapply(sec.item.list, slot, 1L, "id"),
655 672
      item.ref=vapply(sec.item.list, slot, FALSE, "reference"),
656 673
      sec.id=rep(length(e1), sum(item.count)),

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include exec.R
2 18
3 19
NULL
@@ -168,8 +184,10 @@
Loading
168 184
169 185
    # store / record history
170 186
171 -
    if(!is.null(hist.con) && length(val) == 1L)
172 -
      history_write(hist.con, deparse(val[[1L]]))
187 +
    if(!is.null(hist.con) && length(val) == 1L) {
188 +
      dval <- deparse(val[[1L]])
189 +
      history_write(hist.con, dval)
190 +
    }
173 191
    # error or no user input, re-prompt user
174 192
    if(res$aborted || !length(val)) {
175 193
      cat("\n")

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
#' @include unitizer.R
2 18
3 19
NULL

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
2 18
# Strategy for parsing comments:
3 19
#

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
## Store Retrieve Unitizer
2 18
##
3 19
## If this errors, calling function should abort

@@ -1,62 +1,19 @@
Loading
1 -
# Check Whether File Connection Are Valid
2 -
#
3 -
# Use \code{`is.open_con`} to verify that a connection is open in addition to being
4 -
# valid
5 -
#
6 -
# @keywords internal
7 -
# @aliases is.open_con
8 -
# @param x object to test
9 -
# @param file.name 1 length character the name of the file that \code{`x`}
10 -
#   must point to
11 -
# @param readable/writeable whether file must be readable or writeable NA if
12 -
#   you don't care
13 -
# @return TRUE if valid, 1 length character vector if not explaining why it's not
14 -
15 -
is.valid_con <- function(x, file.name=NULL, readable=NA, writeable=NA) {
16 -
  if(!is.null(file.name) && !is.chr1(file.name))
17 -
      stop("Argument `file.name` must be NULL or a one length character vector.")
18 -
  if(!is.lgl.1L(readable) || !is.lgl.1L(writeable))
19 -
    stop("Arguments `readable` and `writeable` must be logical(1L)")
20 -
21 -
  # Basic checks
22 -
23 -
  if(!inherits(x, c("file", "connection")))
24 -
    return("must inherit from \"file\" and \"connection\"")
25 -
  if(!is.integer(x)) return("must be an integer")
26 -
  if(inherits(try(x.chr <- as.character(x)), "try-error"))
27 -
    return("cannot retrieve connection name to test")
28 -
  cons <- showConnections(all=TRUE)
29 -
  if(!isTRUE(x.chr %in% rownames(cons)))
30 -
    return("connection does not exist in `showConnections`")
31 -
32 -
  # Check r/w status
33 -
34 -
  rw <- list(writeable=writeable, readable=readable)
35 -
  rw.s <- list(writeable="write", readable="read")
36 -
  for(i in names(rw))
37 -
    if(!is.na(rw[[i]]))
38 -
      if(
39 -
        (cons[x.chr, sprintf("can %s", rw.s[[i]])] == "yes") != rw[[i]]
40 -
      )
41 -
        return(
42 -
          cc(
43 -
            "connection is ", if(rw[[i]]) "not ", i, " but should ",
44 -
            if(!rw[[i]]) "not ", "be ", i
45 -
        ) )
46 -
47 -
  # Match file name
48 -
49 -
  if(!is.null(file.name)) {
50 -
    if(!identical(file.name, cons[x.chr, "description"]))
51 -
      return("file name does not match connection description")
52 -
  }
53 -
  return(TRUE)
54 -
}
55 -
is.open_con <- function(x, file=NULL, readable=NA, writeable=NA) {
56 -
  if(!isTRUE(msg <- is.valid_con(x, file, readable, writeable))) return(msg)
57 -
  if(!isOpen(x)) return("must be an open connection")
58 -
  return(TRUE)
59 -
}
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
60 17
# Confirm Object is In \code{package_version} form
61 18
# @keywords internal
62 19

@@ -1,3 +1,19 @@
Loading
1 +
# Copyright (C) 2020  Brodie Gaslam
2 +
# 
3 +
# This file is part of "unitizer"
4 +
# 
5 +
# This program is free software: you can redistribute it and/or modify
6 +
# it under the terms of the GNU General Public License as published by
7 +
# the Free Software Foundation, either version 2 of the License, or
8 +
# (at your option) any later version.
9 +
# 
10 +
# This program is distributed in the hope that it will be useful,
11 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 +
# GNU General Public License for more details.
14 +
# 
15 +
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
16 +
1 17
# Retrieves Environment Ancestry
2 18
#
3 19
# @keywords internal
@@ -184,15 +200,11 @@
Loading
184 200
history_write <- function(hist.con, data) {
185 201
  if(is.null(hist.con)) return(invisible(NULL)) # probably in non-interactive
186 202
  # nocov start
187 -
  stopifnot(is.open_con(hist.con), is.character(data))
188 -
  if(is.open_con(hist.con)) {
203 +
  stopifnot(inherits(hist.con, 'connection'), is.character(data))
204 +
  if(isOpen(hist.con)) {
189 205
    cat(data, file=hist.con, sep="\n")
190 206
    if(!isTRUE(attr(hist.con, "no.hist"))) {
191 -
      hist.save <-
192 -
        try(
193 -
          loadhistory(showConnections()[as.character(hist.con), "description"]),
194 -
          silent=TRUE
195 -
        )
207 +
      hist.save <- try(loadhistory(summary(hist.con)$description), silent=TRUE)
196 208
      if(inherits(hist.save, "try-error"))
197 209
        warning(attr(hist.save, "condition"), immediate.=TRUE)
198 210
  } }
Files Coverage
R 93.54%
Project Totals (42 files) 93.54%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading