mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Add quickcheck (#1574)
* Move uptime to being a duration value * Adds our first quickcheck test
This commit is contained in:
parent
18dd009ca8
commit
dd4935fb23
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -2098,6 +2098,8 @@ dependencies = [
|
||||
"prettytable-rs",
|
||||
"ptree",
|
||||
"query_interface",
|
||||
"quickcheck",
|
||||
"quickcheck_macros",
|
||||
"rand",
|
||||
"regex",
|
||||
"roxmltree",
|
||||
@ -2848,6 +2850,29 @@ dependencies = [
|
||||
"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]]
|
||||
name = "quote"
|
||||
version = "1.0.2"
|
||||
|
@ -97,6 +97,10 @@ features = ["bundled", "blob"]
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.12.0", path = "../nu-build" }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
|
||||
[features]
|
||||
stable = []
|
||||
starship-prompt = ["starship"]
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,12 @@ extern crate indexmap;
|
||||
#[macro_use]
|
||||
mod prelude;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate quickcheck;
|
||||
#[cfg(test)]
|
||||
#[macro_use(quickcheck)]
|
||||
extern crate quickcheck_macros;
|
||||
|
||||
mod cli;
|
||||
mod commands;
|
||||
mod context;
|
||||
|
Loading…
Reference in New Issue
Block a user