Add quickcheck (#1574)

* Move uptime to being a duration value

* Adds our first quickcheck test
This commit is contained in:
Jonathan Turner 2020-04-12 07:05:59 +12:00 committed by GitHub
parent 18dd009ca8
commit dd4935fb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 0 deletions

25
Cargo.lock generated
View File

@ -2098,6 +2098,8 @@ dependencies = [
"prettytable-rs", "prettytable-rs",
"ptree", "ptree",
"query_interface", "query_interface",
"quickcheck",
"quickcheck_macros",
"rand", "rand",
"regex", "regex",
"roxmltree", "roxmltree",
@ -2848,6 +2850,29 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "quickcheck"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
dependencies = [
"env_logger",
"log",
"rand",
"rand_core",
]
[[package]]
name = "quickcheck_macros"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.2" version = "1.0.2"

View File

@ -97,6 +97,10 @@ features = ["bundled", "blob"]
[build-dependencies] [build-dependencies]
nu-build = { version = "0.12.0", path = "../nu-build" } nu-build = { version = "0.12.0", path = "../nu-build" }
[dev-dependencies]
quickcheck = "0.9"
quickcheck_macros = "0.9"
[features] [features]
stable = [] stable = []
starship-prompt = ["starship"] starship-prompt = ["starship"]

View File

@ -776,3 +776,19 @@ pub fn print_err(err: ShellError, host: &dyn Host, source: &Text) {
); );
}); });
} }
#[cfg(test)]
mod tests {
#[quickcheck]
fn quickcheck_parse(data: String) -> bool {
if let Ok(lite_pipeline) = nu_parser::lite_parse(&data, 0) {
let context = crate::context::Context::basic().unwrap();
nu_parser::classify_pipeline(&lite_pipeline, context.registry())
.failed
.is_none()
} else {
false
}
}
}

View File

@ -7,6 +7,12 @@ extern crate indexmap;
#[macro_use] #[macro_use]
mod prelude; mod prelude;
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
mod cli; mod cli;
mod commands; mod commands;
mod context; mod context;