mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
mod function
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
Anand Krishnamoorthi
parent
b30fc2599c
commit
a8a1d4b820
@@ -142,3 +142,117 @@ cases:
|
||||
x = numbers.range(1, "2")
|
||||
query: data.test.x
|
||||
error: "`numbers.range` expects numeric argument"
|
||||
|
||||
- note: round
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = [round(-9.4), round(-9.5), round(-9.6),
|
||||
round(9.4), round(9.5), round(9.6)]
|
||||
query: data.test.x
|
||||
want_result: [-9, -10, -10, 9, 10, 10]
|
||||
|
||||
- note: round-extra-args
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = round(-9, 10)
|
||||
query: data.test.x
|
||||
error: "`round` expects 1 argument"
|
||||
|
||||
- note: round-invalid-type
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = round("-9")
|
||||
query: data.test.x
|
||||
error: "`round` expects numeric argument"
|
||||
|
||||
- note: div
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 1/3
|
||||
query: data.test.x
|
||||
want_result: 0.3333333333333333
|
||||
|
||||
- note: div-non-numeric
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = "1" / 9
|
||||
query: data.test.x
|
||||
error: "`div` expects numeric argument."
|
||||
|
||||
- note: div-undefined
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
import future.keywords.if
|
||||
a if false
|
||||
x = a / 1
|
||||
query: data.test
|
||||
want_result: {}
|
||||
|
||||
- note: div-by-zero
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 1/0
|
||||
query: data.test
|
||||
want_result: {}
|
||||
|
||||
- note: mod
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 10%3
|
||||
query: data.test.x
|
||||
want_result: 1
|
||||
|
||||
- note: mod-non-numeric
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = "1" % 9
|
||||
query: data.test.x
|
||||
error: "`mod` expects numeric argument."
|
||||
|
||||
- note: mod-undefined
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
import future.keywords.if
|
||||
a if false
|
||||
x = a % 10
|
||||
query: data.test
|
||||
want_result: {}
|
||||
|
||||
- note: mod-by-zero
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 1%0
|
||||
query: data.test
|
||||
want_result: {}
|
||||
|
||||
- note: all
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 16 / 2 % 5 / 2
|
||||
query: data.test
|
||||
want_result:
|
||||
x: 1.5
|
||||
|
||||
Reference in New Issue
Block a user