mirror of
https://github.com/nushell/nushell.git
synced 2025-06-05 17:46:44 +02:00
# Description This pull request addresses an issue#15813 where passing a infinite value in the random float 1.. command that causes a panic in the shell. The root cause of this problem lies within the rng library, which is responsible for generating random numbers. Before  # User-Facing Changes Users where seeing panic error when passed unbounded end into range. # Tests + Formatting added `generate_inf` # After Submitting  No error should be there after Edit history 1. Updated `After Submitting` section --------- Co-authored-by: Ritik Ranjan <e02948@ritik.ranjan@hsc.com>
33 lines
677 B
Rust
33 lines
677 B
Rust
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn generates_a_float() {
|
|
let actual = nu!("random float 42..43");
|
|
|
|
// Attention: this relies on the string output
|
|
assert!(actual.out.starts_with("42") || actual.out.starts_with("43"));
|
|
let actual = nu!("random float 42..43 | describe");
|
|
|
|
assert_eq!(actual.out, "float")
|
|
}
|
|
|
|
#[test]
|
|
fn generates_55() {
|
|
let actual = nu!("random float 55..55");
|
|
|
|
assert!(actual.out.contains("55"));
|
|
}
|
|
|
|
#[test]
|
|
fn generates_0() {
|
|
let actual = nu!("random float ..<1");
|
|
|
|
assert!(actual.out.contains('0'));
|
|
}
|
|
|
|
#[test]
|
|
fn generate_inf() {
|
|
let actual = nu!("random float 1.. | describe");
|
|
assert_eq!(actual.out, "float");
|
|
}
|