summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/compute/calc.rs4
-rw-r--r--tests/typ/compute/calc.typ4
2 files changed, 8 insertions, 0 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index 5f5c2b4a..d3319d76 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -30,6 +30,10 @@ pub fn calc() -> Module {
scope.def_func::<EvenFunc>("even");
scope.def_func::<OddFunc>("odd");
scope.def_func::<ModFunc>("mod");
+ scope.define("inf", Value::Float(f64::INFINITY));
+ scope.define("nan", Value::Float(f64::NAN));
+ scope.define("pi", Value::Float(std::f64::consts::PI));
+ scope.define("e", Value::Float(std::f64::consts::E));
Module::new("calc").with_scope(scope)
}
diff --git a/tests/typ/compute/calc.typ b/tests/typ/compute/calc.typ
index 195e3285..67579493 100644
--- a/tests/typ/compute/calc.typ
+++ b/tests/typ/compute/calc.typ
@@ -13,6 +13,10 @@
#test(type(float(10)), "float")
---
+#test(calc.round(calc.e, digits: 2), 2.72)
+#test(calc.round(calc.pi, digits: 2), 3.14)
+
+---
// Error: 6-10 expected boolean, integer, float, or string, found length
#int(10pt)