Range refactor (#12405)

# Description
Currently, `Range` is a struct with a `from`, `to`, and `incr` field,
which are all type `Value`. This PR changes `Range` to be an enum over
`IntRange` and `FloatRange` for better type safety / stronger compile
time guarantees.

Fixes: #11778 Fixes: #11777 Fixes: #11776 Fixes: #11775 Fixes: #11774
Fixes: #11773 Fixes: #11769.

# User-Facing Changes
Hopefully none, besides bug fixes.

Although, the `serde` representation might have changed.
This commit is contained in:
Ian Manske
2024-04-06 14:04:56 +00:00
committed by GitHub
parent 75fedcc8dd
commit 7a7d43344e
27 changed files with 1126 additions and 798 deletions

View File

@ -229,11 +229,13 @@ fn unbounded_from_in_range_fails() {
#[test]
fn inf_in_range_fails() {
let actual = nu!(r#"inf..5 | to json"#);
assert!(actual.err.contains("Cannot create range"));
assert!(actual.err.contains("can't convert to countable values"));
let actual = nu!(r#"5..inf | to json"#);
assert!(actual.err.contains("Cannot create range"));
assert!(actual
.err
.contains("Unbounded ranges are not allowed when converting to this format"));
let actual = nu!(r#"-inf..inf | to json"#);
assert!(actual.err.contains("Cannot create range"));
assert!(actual.err.contains("can't convert to countable values"));
}
#[test]