UPDATE: Adds 56 functions in the Statistical section

Uses statrs for numerical functions

REFACTOR: Put statistical functions on its own module

This might seem counter-intuitive but the wasm build after this refactor
is 1528 bytes smaller :)
This commit is contained in:
Nicolás Hatcher
2025-11-20 21:10:47 +01:00
committed by Nicolás Hatcher Andrés
parent 67ef3bcf87
commit 6822505602
54 changed files with 7290 additions and 387 deletions

View File

@@ -0,0 +1,50 @@
#![allow(clippy::unwrap_used)]
use crate::test::util::new_empty_model;
#[test]
fn arguments_smoke_test() {
let mut model = new_empty_model();
model._set("A1", "=DEVSQ()");
model._set("A2", "=DEVSQ(1, 2, 3)");
model._set("A3", "=DEVSQ(1, )");
model._set("A4", "=DEVSQ(1, , 3)");
model.evaluate();
assert_eq!(model._get_text("A1"), *"#ERROR!");
assert_eq!(model._get_text("A2"), *"2");
assert_eq!(model._get_text("A3"), *"0");
assert_eq!(model._get_text("A4"), *"2");
}
#[test]
fn ranges() {
let mut model = new_empty_model();
model._set("A1", "=DEVSQ(A2:A8)");
model._set("A2", "4");
model._set("A3", "5");
model._set("A4", "8");
model._set("A5", "7");
model._set("A6", "11");
model._set("A7", "4");
model._set("A8", "3");
model.evaluate();
assert_eq!(model._get_text("A1"), *"48");
}
#[test]
fn arrays() {
let mut model = new_empty_model();
model._set("A1", "=DEVSQ({1, 2, 3})");
model._set("A2", "=DEVSQ({1; 2; 3})");
model._set("A3", "=DEVSQ({1, 2; 3, 4})");
model._set("A4", "=DEVSQ({1, 2; 3, 4; 5, 6})");
model.evaluate();
assert_eq!(model._get_text("A1"), *"2");
assert_eq!(model._get_text("A2"), *"2");
assert_eq!(model._get_text("A3"), *"5");
assert_eq!(model._get_text("A4"), *"17.5");
}