mirror of
https://github.com/nushell/nushell.git
synced 2025-06-04 00:56:11 +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>
This commit is contained in:
parent
9a968c4bdd
commit
1b2079ffdb
@ -90,7 +90,7 @@ fn float(
|
||||
let value = match range.end() {
|
||||
Bound::Included(end) => random_range(range.start()..=end),
|
||||
Bound::Excluded(end) => random_range(range.start()..end),
|
||||
Bound::Unbounded => random_range(range.start()..f64::INFINITY),
|
||||
Bound::Unbounded => random_range(range.start()..f64::MAX),
|
||||
};
|
||||
|
||||
Ok(PipelineData::Value(Value::float(value, span), None))
|
||||
|
@ -24,3 +24,9 @@ fn generates_0() {
|
||||
|
||||
assert!(actual.out.contains('0'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generate_inf() {
|
||||
let actual = nu!("random float 1.. | describe");
|
||||
assert_eq!(actual.out, "float");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user