# Copyright (C) Brodie Gaslam
#
# This file is part of "vetr - Trust, but Verify"
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.

vetr:::val_all(c(rep(TRUE, 5), NA, rep(TRUE, 5)))

capt_wo_time <- function(x) {
    txt <- capture.output(x)
    gsub("~ *-?[0-9.e+\\-]*", "~", txt)
}

# three different time frames that should trigger all the code, need to remove
# the time piece so that the tests don't fail due to variations

Mean eval time from 1 iteration, in seconds:
Sys.sleep(1.2)  ~

[1] "Mean eval time from 1 iteration, in seconds:"
[2] "  Sys.sleep(1.2)  ~"

Mean eval time from 10 iterations, in milliseconds:
Sys.sleep(0.01)  ~

[1] "Mean eval time from 10 iterations, in milliseconds:"
[2] "  Sys.sleep(0.01)  ~"

capt_wo_time(bench_mark(1 + 1, NULL, times = 100))

Mean eval time from 100 iterations, in microseconds:

[1] "Mean eval time from 100 iterations, in microseconds:"
[2] "  1 + 1  ~"                                          
[3] "  NULL   ~"

vetr:::list_as_sorted_vec(list(c = 1, a = list(), b = NULL))

vetr:::list_as_sorted_vec(list(b = 1, 2, a = 3))

# # equal names not stable, but we should never hit this with attribute lists