mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 03:51:23 +08:00
d1ca392393
It's always a bit annoying that `*` requires quoting. So we allow "x" as an alternative, only it needs to be followed by whitespace to distinguish it from "0x" hexadecimal notation.
62 lines
1.0 KiB
Fish
62 lines
1.0 KiB
Fish
logmsg Validate basic expressions
|
|
math 3 / 2
|
|
math 10/6
|
|
math -s0 10 / 6
|
|
math 'floor(10 / 6)'
|
|
math -s3 10/6
|
|
math '10 % 6'
|
|
math -s0 '10 % 6'
|
|
math '23 % 7'
|
|
math --scale=6 '5 / 3 * 0.3'
|
|
math --scale=max '5 / 3'
|
|
math "7^2"
|
|
math -1 + 1
|
|
math '-2 * -2'
|
|
math 5 \* -2
|
|
math -- -4 / 2
|
|
math -- '-4 * 2'
|
|
|
|
logmsg Validate some rounding functions
|
|
math 'round(3/2)' ; math 'floor(3/2)' ; math 'ceil(3/2)'
|
|
math 'round(-3/2)' ; math 'floor(-3/2)' ; math 'ceil(-3/2)'
|
|
|
|
logmsg Validate some integral computations
|
|
math 1
|
|
math 10
|
|
math 100
|
|
math 1000
|
|
math '10^15'
|
|
math '-10^14'
|
|
math '-10^15'
|
|
|
|
math -s0 '1.0 / 2.0'
|
|
math -s0 '3.0 / 2.0'
|
|
math -s0 '10^15 / 2.0'
|
|
|
|
logmsg Validate how variables in an expression are handled
|
|
math $x + 1
|
|
set x 1
|
|
math $x + 1
|
|
set x 3
|
|
set y 1.5
|
|
math "-$x * $y"
|
|
math -s0 "-$x * $y"
|
|
|
|
logmsg Validate math error reporting
|
|
not math '2 - '
|
|
not math 'ncr(1)'
|
|
not math 'max()'
|
|
not math 'sin()'
|
|
not math '2 + 2 4'
|
|
not math
|
|
not math -s 12
|
|
not math 2^999999
|
|
not math 1 / 0
|
|
|
|
logmsg Validate "x" as multiplier
|
|
math 0x2 # Hex
|
|
math 5 x 4
|
|
math 2x 4
|
|
math 2 x4 # ERROR
|
|
math 0x 3
|