snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
148
server/pkg/expr/func_num_test.go
Normal file
148
server/pkg/expr/func_num_test.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package expr
|
||||
|
||||
func Example_min() {
|
||||
eval(`min(2, 1, 3)`, nil)
|
||||
|
||||
// output:
|
||||
// 1
|
||||
}
|
||||
|
||||
func Example_max() {
|
||||
eval(`max(2, 1, 3)`, nil)
|
||||
|
||||
// output:
|
||||
// 3
|
||||
}
|
||||
|
||||
func Example_round() {
|
||||
eval(`round(3.14,1)`, nil)
|
||||
|
||||
// output:
|
||||
// 3.1
|
||||
}
|
||||
|
||||
func Example_floor() {
|
||||
eval(`floor(3.14)`, nil)
|
||||
|
||||
// output:
|
||||
// 3
|
||||
}
|
||||
|
||||
func Example_ceil() {
|
||||
eval(`ceil(3.14)`, nil)
|
||||
|
||||
// output:
|
||||
// 4
|
||||
}
|
||||
|
||||
func Example_abs() {
|
||||
eval(`abs(-3.14)`, nil)
|
||||
|
||||
// output:
|
||||
// 3.14
|
||||
}
|
||||
|
||||
func Example_log() {
|
||||
eval(`log(100)`, nil)
|
||||
|
||||
// output:
|
||||
// 2
|
||||
}
|
||||
|
||||
func Example_ln() {
|
||||
eval(`pow(2, 3)`, nil)
|
||||
|
||||
// output:
|
||||
// 8
|
||||
}
|
||||
|
||||
func Example_sqrt() {
|
||||
eval(`sqrt(16)`, nil)
|
||||
|
||||
// output:
|
||||
// 4
|
||||
}
|
||||
|
||||
func Example_sum() {
|
||||
eval(`sum(1, 2, "foo", 3.4, 4, "3")`, 10.4)
|
||||
|
||||
// output:
|
||||
// 13.4
|
||||
}
|
||||
|
||||
func Example_average() {
|
||||
eval(`average(1, 2, 3, "foo", 10)`, 10.4)
|
||||
|
||||
// output:
|
||||
// 4
|
||||
}
|
||||
|
||||
func Example_randomWithSingleInput() {
|
||||
eval(`max(random(6), 7)`, nil)
|
||||
|
||||
// output:
|
||||
// 7
|
||||
}
|
||||
|
||||
func Example_randomWithTwoInput() {
|
||||
eval(`min(random(2, 6), 1)`, nil)
|
||||
|
||||
// output:
|
||||
// 1
|
||||
}
|
||||
|
||||
func Example_castStringToInt() {
|
||||
eval(`int("abc")`, nil)
|
||||
|
||||
// output:
|
||||
// 0
|
||||
}
|
||||
|
||||
func Example_castStringNumberToInt() {
|
||||
eval(`int("42690")`, nil)
|
||||
|
||||
// output:
|
||||
// 42690
|
||||
}
|
||||
|
||||
func Example_castFloatToInt() {
|
||||
eval(`int("42.690")`, nil)
|
||||
|
||||
// output:
|
||||
// 0
|
||||
}
|
||||
|
||||
func Example_castStringWithLeadingZero08() {
|
||||
eval(`int("08")`, nil)
|
||||
|
||||
// output:
|
||||
// 8
|
||||
}
|
||||
|
||||
func Example_castStringWithLeadingZero09() {
|
||||
eval(`int("09")`, nil)
|
||||
|
||||
// output:
|
||||
// 9
|
||||
}
|
||||
|
||||
func Example_castStringWithLeadingZero010() {
|
||||
eval(`int("010")`, nil)
|
||||
|
||||
// output:
|
||||
// 10
|
||||
}
|
||||
|
||||
func Example_castStringWithLeadingZero011() {
|
||||
eval(`int("011")`, nil)
|
||||
|
||||
// output:
|
||||
// 11
|
||||
}
|
||||
|
||||
func Example_castStringWithLeadingZero012() {
|
||||
eval(`int("012")`, nil)
|
||||
|
||||
// output:
|
||||
// 12
|
||||
}
|
||||
Reference in New Issue
Block a user