mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Allow underscores in integers and floats (#7759)
# Description This PR makes changes that allow underscores in numbers. Example: ```nu # allows underscores to be placed arbitrarily to enhance readability. let pi = 3.1415_9265_3589_793 # works with integers let num = 1_000_000_000_000 let fav_color = 0x68_9d_6a ```
This commit is contained in:
@ -18,6 +18,31 @@ fn alias_1() -> TestResult {
|
||||
run_test("def foo [$x] { $x + 10 }; alias f = foo; f 100", "110")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ints_with_underscores() -> TestResult {
|
||||
run_test("1_0000_0000_0000 + 10", "1000000000010")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn floats_with_underscores() -> TestResult {
|
||||
run_test("3.1415_9265_3589_793 * 2", "6.283185307179586")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bin_ints_with_underscores() -> TestResult {
|
||||
run_test("0b_10100_11101_10010", "21426")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oct_ints_with_underscores() -> TestResult {
|
||||
run_test("0o2443_6442_7652_0044", "90422533333028")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hex_ints_with_underscores() -> TestResult {
|
||||
run_test("0x68__9d__6a", "6856042")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alias_2() -> TestResult {
|
||||
run_test(
|
||||
|
Reference in New Issue
Block a user