From beb9af526e08bf6495adc7184535f289ef365519 Mon Sep 17 00:00:00 2001 From: danielvartan Date: Fri, 18 Oct 2024 03:04:22 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20danielva?= =?UTF-8?q?rtan/prettycheck@4d16b06b42179bf5b20530186a6a0d861291bed6=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE.html | 35 ++++++ index.html | 6 +- pkgdown.yml | 2 +- reference/assert_identical.html | 4 +- reference/assert_length.html | 4 +- reference/assert_pick.html | 4 +- reference/check_identical.html | 147 +++++++++++++++++++++++-- reference/check_length.html | 185 ++++++++++++++++++++++++++++++-- reference/check_pick.html | 181 +++++++++++++++++++++++++++++-- reference/index.html | 6 +- reference/test_identical.html | 153 ++------------------------ reference/test_length.html | 141 ++---------------------- reference/test_pick.html | 164 ++-------------------------- sitemap.xml | 6 +- 14 files changed, 564 insertions(+), 474 deletions(-) diff --git a/LICENSE.html b/LICENSE.html index 51e050a..704ddc6 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -46,6 +46,7 @@

MIT License

+

Copyright (c) 2024 Daniel Vartanian

@@ -53,6 +54,40 @@

MIT License

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+
+

Third-party licenses

+

This package incorporates C code from the checkmate R package, linked via the LinkingTo field in the DESCRIPTION file. The code is released under the 3-Clause BSD License, as indicated in the license notice below.

+

Additionally, it is worth noting that the MIT License is compatible with the BSD-3-Clause License.

+
Copyright (c) 2023, Michel Lang
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+    Neither the name of the <ORGANIZATION> nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+
+ diff --git a/index.html b/index.html index 0c00b39..44055ab 100644 --- a/index.html +++ b/index.html @@ -92,11 +92,11 @@

Usage

Here are some of the functions available for now:

Click here to see the full list of functions.

diff --git a/pkgdown.yml b/pkgdown.yml index cbcdcb6..82cb998 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.1.1 pkgdown_sha: ~ articles: {} -last_built: 2024-10-17T07:50Z +last_built: 2024-10-18T03:04Z urls: reference: https://danielvartan.github.io/prettycheck/reference article: https://danielvartan.github.io/prettycheck/articles diff --git a/reference/assert_identical.html b/reference/assert_identical.html index aa909fb..a8e17b1 100644 --- a/reference/assert_identical.html +++ b/reference/assert_identical.html @@ -1,8 +1,8 @@ - + - + diff --git a/reference/assert_length.html b/reference/assert_length.html index a77715d..ea1fe7d 100644 --- a/reference/assert_length.html +++ b/reference/assert_length.html @@ -1,8 +1,8 @@ - + - + diff --git a/reference/assert_pick.html b/reference/assert_pick.html index 5be1327..82b979a 100644 --- a/reference/assert_pick.html +++ b/reference/assert_pick.html @@ -1,8 +1,8 @@ - + - + diff --git a/reference/check_identical.html b/reference/check_identical.html index aa909fb..a424531 100644 --- a/reference/check_identical.html +++ b/reference/check_identical.html @@ -1,8 +1,141 @@ - - - - - - - + +Check if multiple objects are identical — check_identical • prettycheck + + +
+
+ + + +
+
+ + +
+

[Experimental]

+
+ +
+
check_identical(..., type = "value", .names = get_names(...))
+
+assert_identical(..., type = "value", .names = get_names(...))
+
+test_identical(..., type = "value", .names = get_names(...))
+
+ +
+

Arguments

+ + +
...
+

Objects to compare.

+ + +
type
+

(optional) a string corresponding to the type of comparison to +perform. Valid values: "value", "length", and "class" (default: +"value").

+ + +
.names
+

(optional) a character vector +containing names for each object in ... (default: +prettycheck:::get_names(...)). This argument is used internally and +should not be set by the user.

+ +
+
+

Value

+ +
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • +
  • check_*: TRUE if it passes the test; a string with a message otherwise.

  • +
  • assertion_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
  • expect_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
+ +
+

Examples

+
x <- 1; y <- 1
+test_identical(x, y, type = "value")
+#> [1] TRUE
+#> [1] TRUE # Expected
+
+x <- 1; y <- 2
+check_identical(x, y, type = "value") |> cli::cli_alert_warning()
+#> ! x and y must have identical values.
+#> ! x and y must have identical values. # Expected
+
+x <- letters; y <- 1:2
+check_identical(x, y, type = "length") |> cli::cli_alert_warning()
+#> ! x and y must have identical lengths.
+#> ! x and y must have identical lengths. # Expected
+
+x <- "a"; y <- 1
+check_identical(x, y, type = "class") |> cli::cli_alert_warning()
+#> ! x and y must belong to the same class.
+#> ! x and y must belong to the same class. # Expected
+
+
+
+ +
+ + +
+ + + + + + + diff --git a/reference/check_length.html b/reference/check_length.html index a77715d..30e8e62 100644 --- a/reference/check_length.html +++ b/reference/check_length.html @@ -1,8 +1,179 @@ - - - - - - - + +Check if an argument has a specific length — check_length • prettycheck + + +
+
+ + + +
+
+ + +
+

[Experimental]

+
+ +
+
check_length(
+  x,
+  len = 1,
+  min_len = NULL,
+  max_len = NULL,
+  null_ok = FALSE,
+  .names = deparse(substitute(x))
+)
+
+assert_length(
+  x,
+  len = 1,
+  min_len = NULL,
+  max_len = NULL,
+  null_ok = FALSE,
+  .names = deparse(substitute(x))
+)
+
+test_length(
+  x,
+  len = 1,
+  min_len = NULL,
+  max_len = NULL,
+  null_ok = FALSE,
+  .names = deparse(substitute(x))
+)
+
+ +
+

Arguments

+ + +
x
+

An R object.

+ + +
len
+

(optional) an integer number indicating the expected length of x +(default: 1).

+ + +
min_len
+

(optional) an integer number indicating the minimum length of +x (default: NULL).

+ + +
max_len
+

(optional) an integer number indicating the maximum length of +x (default: NULL).

+ + +
null_ok
+

(optional) a logical flag indicating +if x can be NULL (default: FALSE).

+ + +
.names
+

(optional) a character vector +containing names for each object in ... (default: +deparse(substitute(x))). This argument is used internally and should +not be set by the user.

+ +
+
+

Value

+ +
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • +
  • check_*: TRUE if it passes the test; a string with a message otherwise.

  • +
  • assertion_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
  • expect_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
+ +
+

Examples

+
x <- 1:2
+
+test_length(x, len = 2)
+#> [1] TRUE
+#> [1] TRUE # Expected
+
+check_length(x, len = 1) |> cli::cli_alert_warning()
+#> ! x must have 1  element.
+#> ! x must have 1 element. # Expected
+
+check_length(x, min_len = 3) |> cli::cli_alert_warning()
+#> ! x must have 3 or more elements.
+#> ! x must have 3 or more elements. # Expected
+
+check_length(x, max_len = 1) |> cli::cli_alert_warning()
+#> ! x must have 1 or less elements.
+#> ! x must have 1 or less elements. # Expected
+
+x <- 1
+check_length(x, min_len = 2, max_len = 3) |> cli::cli_alert_warning()
+#> ! x must have a length between 2 and 3.
+#> ! x must have a length between 2 and 3. # Expected
+
+
+
+ +
+ + +
+ + + + + + + diff --git a/reference/check_pick.html b/reference/check_pick.html index 5be1327..0083f14 100644 --- a/reference/check_pick.html +++ b/reference/check_pick.html @@ -1,8 +1,175 @@ - - - - - - - + +Check how many arguments were picked — check_pick • prettycheck + + +
+
+ + + +
+
+ + +
+

[Experimental]

+

want to limit the number of arguments that can be assigned in a function.

+
+ +
+
check_pick(
+  ...,
+  pick = NULL,
+  min_pick = NULL,
+  max_pick = NULL,
+  .names = get_names(...)
+)
+
+assert_pick(
+  ...,
+  pick = NULL,
+  min_pick = NULL,
+  max_pick = NULL,
+  .names = get_names(...)
+)
+
+test_pick(
+  ...,
+  pick = NULL,
+  min_pick = NULL,
+  max_pick = NULL,
+  .names = get_names(...)
+)
+
+ +
+

Arguments

+ + +
...
+

Objects to compare.

+ + +
pick
+

(optional) an integer number indicating the expected number of +arguments to pick (default: NULL) (default: 1).

+ + +
min_pick
+

(optional) an integer number indicating the minimum number of +arguments to pick (default: NULL).

+ + +
max_pick
+

(optional) an integer number indicating the maximum number of +arguments to pick (default: NULL).

+ + +
.names
+

(optional) a character vector +containing names for each object in ... (default: +prettycheck:::get_names(...)). This argument is used internally and +should not be set by the user.

+ +
+
+

Value

+ +
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • +
  • check_*: TRUE if it passes the test; a string with a message otherwise.

  • +
  • assertion_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
  • expect_*: The same input as invisible if it passes the +test; an error message otherwise.

  • +
+ +
+

Examples

+
x <- 1; y <- NULL
+test_pick(x, y, pick = 1)
+#> [1] TRUE
+#> [1] TRUE # Expected
+
+x <- 1; y <- NULL; z <- NULL
+check_pick(x, y, z, pick = 2) |> cli::cli_alert_warning()
+#> ! You must pick 2 of the x, y and z arguments.
+#> ! You must pick 2 of the x, y and z arguments. # Expected
+
+x <- 1; y <- NULL
+check_pick(x, y, min_pick = 2) |> cli::cli_alert_warning()
+#> ! You must assign the x and y arguments.
+#> ! You must assign the x and y arguments. # Expected
+
+x <- 1; y <- NULL; z <- NULL
+check_pick(x, y, z, min_pick = 2) |> cli::cli_alert_warning()
+#> ! You must pick 2 or more of the x, y and z arguments.
+#> ! You must pick 2 or more of the x, y and z arguments. # Expected
+
+x <- 1; y <- 1; z <- NULL
+check_pick(x, y, z, max_pick = 1) |> cli::cli_alert_warning()
+#> ! You must pick 1 or less of the x, y and z arguments.
+#> ! You must pick 1 or less of the x, y and z arguments. # Expected
+
+
+
+ +
+ + +
+ + + + + + + diff --git a/reference/index.html b/reference/index.html index 90569bf..1845915 100644 --- a/reference/index.html +++ b/reference/index.html @@ -51,15 +51,15 @@

Checks <

prettycheck includes four main types of functions: test_*(), check_*(), assert_*(), and expect_*(). The test_*() functions return a logical flag; the check_*() functions return a logical flag and throw a warning message if the condition is not met; and theassert_*() and expect_*() functions return a logical flag and throw an error if the condition is not met.

-

test_identical() check_identical() assert_identical() expect_identical()

+

check_identical() assert_identical() test_identical()

Check if multiple objects are identical

-

test_length() check_length() assert_length() expect_length()

+

check_length() assert_length() test_length()

Check if an argument has a specific length

-

test_pick() check_pick() assert_pick()

+

check_pick() assert_pick() test_pick()

Check how many arguments were picked

diff --git a/reference/test_identical.html b/reference/test_identical.html index d40f7ce..a8e17b1 100644 --- a/reference/test_identical.html +++ b/reference/test_identical.html @@ -1,147 +1,8 @@ - -Check if multiple objects are identical — test_identical • prettycheck - - -
-
- - - -
-
- - -
-

[Experimental]

-
- -
-
test_identical(..., type = "value")
-
-check_identical(..., type = "value")
-
-assert_identical(..., type = "value")
-
-expect_identical(..., type = "value")
-
- -
-

Arguments

- - -
...
-

Objects to compare.

- - -
type
-

(optional) a string corresponding to the type of comparison to -perform. Valid values: "value", "length", and "class" (default: -"value").

- -
-
-

Value

- -
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • -
  • check_*: The same input as invisible if it passes the -test; a warning message otherwise.

  • -
  • assertion_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
  • expect_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
- -
-

Examples

-
x <- 1; y <- 1
-test_identical(x, y, type = "value")
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-x <- 1; y <- 2
-check_identical(x, y, type = "value")
-#> ! x and y must have identical values.
-#> ! x and y must have identical values. # Expected
-
-x <- letters; y <- LETTERS
-test_identical(x, y, type = "length")
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-x <- letters; y <- 1:2
-check_identical(x, y, type = "length")
-#> ! x and y must have identical lengths.
-#> ! x and y must have identical lengths. # Expected
-
-x <- "a"; y <- c("a", "b")
-test_identical(x, y, type = "class")
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-x <- "a"; y <- 1
-check_identical(x, y, type = "class")
-#> ! x and y must belong to the same class.
-#> ! x and y must belong to the same class. # Expected
-
-
-
- -
- - -
- - - - - - - + + + + + + + diff --git a/reference/test_length.html b/reference/test_length.html index 59e683e..ea1fe7d 100644 --- a/reference/test_length.html +++ b/reference/test_length.html @@ -1,135 +1,8 @@ - -Check if an argument has a specific length — test_length • prettycheck - - -
-
- - - -
-
- - -
-

[Experimental]

-
- -
-
test_length(x, len = NULL, min_len = NULL, max_len = NULL, null_ok = FALSE)
-
-check_length(x, len = NULL, min_len = NULL, max_len = NULL, null_ok = FALSE)
-
-assert_length(x, len = NULL, min_len = NULL, max_len = NULL, null_ok = FALSE)
-
-expect_length(x, len = NULL, min_len = NULL, max_len = NULL, null_ok = FALSE)
-
- -
-

Arguments

- - -
x
-

An R object.

- - -
len
-

(optional) an integer number indicating the expected length of x -(default: NULL).

- - -
min_len
-

(optional) an integer number indicating the minimum length of -x (default: NULL).

- - -
max_len
-

(optional) an integer number indicating the maximum length of -x (default: NULL).

- - -
null_ok
-

(optional) a logical flag indicating -if x can be NULL (default: FALSE).

- -
-
-

Value

- -
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • -
  • check_*: The same input as invisible if it passes the -test; a warning message otherwise.

  • -
  • assertion_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
  • expect_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
- -
-

Examples

-
test_length(1, len = 1)
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-
-
- -
- - -
- - - - - - - + + + + + + + diff --git a/reference/test_pick.html b/reference/test_pick.html index c58a495..82b979a 100644 --- a/reference/test_pick.html +++ b/reference/test_pick.html @@ -1,158 +1,8 @@ - -Check how many arguments were picked — test_pick • prettycheck - - -
-
- - - -
-
- - -
-

[Experimental]

-

want to limit the number of arguments that can be assigned in a function.

-
- -
-
test_pick(..., pick = NULL, min_pick = NULL, max_pick = NULL)
-
-check_pick(..., pick = NULL, min_pick = NULL, max_pick = NULL)
-
-assert_pick(..., pick = NULL, min_pick = NULL, max_pick = NULL)
-
- -
-

Arguments

- - -
...
-

Objects to compare.

- - -
pick
-

(optional) an integer number indicating the expected number of -arguments to pick (default: NULL) (default: 1).

- - -
min_pick
-

(optional) an integer number indicating the minimum number of -arguments to pick (default: NULL).

- - -
max_pick
-

(optional) an integer number indicating the maximum number of -arguments to pick (default: NULL).

- -
-
-

Value

- -
  • test_*: TRUE if it passes the test; FALSE otherwise.

  • -
  • check_*: The same input as invisible if it passes the -test; a warning message otherwise.

  • -
  • assertion_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
  • expect_*: The same input as invisible if it passes the -test; an error message otherwise.

  • -
- -
-

Examples

-
x <- 1; y <- NULL
-test_pick(x, y, pick = 1)
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-x <- 1; y <- NULL; z <- NULL
-check_pick(x, y, z, pick = 2)
-#> ! You must pick 2 of the x, y and z arguments.
-#> ! You must pick 2 of the x, y and z arguments. # Expected
-
-x <- 1; y <- NULL
-test_pick(x, y, min_pick = 1)
-#> [1] TRUE
-#> [1] TRUE # Expected
-
-x <- 1; y <- NULL; z <- NULL
-check_pick(x, y, z, min_pick = 2)
-#> Error in else_error(): Something has gone wrong. Please report this issue at
-#> <https://github.com/danielvartan/prettycheck/issues>.
-#> ! You must pick 2 or more arguments. # Expected
-
-x <- 1; y <- 1; z <- NULL
-test_pick(x, y, z, max_pick = 1)
-#> [1] FALSE
-#> [1] FALSE # Expected
-
-x <- 1; y <- 1; z <- NULL
-check_pick(x, y, max_pick = 1)
-#> Error in else_error(): Something has gone wrong. Please report this issue at
-#> <https://github.com/danielvartan/prettycheck/issues>.
-#> ! You must pick 1 or less arguments. # Expected
-
-
-
- -
- - -
- - - - - - - + + + + + + + diff --git a/sitemap.xml b/sitemap.xml index 7164338..1e6a6b6 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -7,10 +7,10 @@ https://danielvartan.github.io/prettycheck/authors.html https://danielvartan.github.io/prettycheck/index.html https://danielvartan.github.io/prettycheck/news/index.html +https://danielvartan.github.io/prettycheck/reference/check_identical.html +https://danielvartan.github.io/prettycheck/reference/check_length.html +https://danielvartan.github.io/prettycheck/reference/check_pick.html https://danielvartan.github.io/prettycheck/reference/index.html https://danielvartan.github.io/prettycheck/reference/prettycheck-package.html -https://danielvartan.github.io/prettycheck/reference/test_identical.html -https://danielvartan.github.io/prettycheck/reference/test_length.html -https://danielvartan.github.io/prettycheck/reference/test_pick.html