From 482de8da4c03ba5b13bd811127d2d564b20b8173 Mon Sep 17 00:00:00 2001 From: cowuake Date: Mon, 19 Aug 2024 07:54:01 +0200 Subject: [PATCH] Fix numerical constants for non-default floats --- schemius/src/core/s_expression/s_number.rs | 15 ++++++++------- schemius/tests/sparse.rs | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/schemius/src/core/s_expression/s_number.rs b/schemius/src/core/s_expression/s_number.rs index d5c4538..378243f 100644 --- a/schemius/src/core/s_expression/s_number.rs +++ b/schemius/src/core/s_expression/s_number.rs @@ -48,13 +48,14 @@ pub enum SNumber { pub struct NumericalConstant; impl NumericalConstant { - pub const AVOGADRO: SNumber = SNumber::Float(numbers::AVOGADRO); - pub const BOLTZMANN: SNumber = SNumber::Float(numbers::BOLTZMANN); - pub const EULER: SNumber = SNumber::Float(numbers::EULER); - pub const GOLDEN_RATIO: SNumber = SNumber::Float(numbers::GOLDEN_RATIO); - pub const GRAVITATIONAL_CONSTANT: SNumber = SNumber::Float(numbers::GRAVITATIONAL_CONSTANT); - pub const PI: SNumber = SNumber::Float(numbers::PI); - pub const PLANCK: SNumber = SNumber::Float(numbers::PLANCK); + pub const AVOGADRO: SNumber = SNumber::Float(numbers::AVOGADRO as NativeFloat); + pub const BOLTZMANN: SNumber = SNumber::Float(numbers::BOLTZMANN as NativeFloat); + pub const EULER: SNumber = SNumber::Float(numbers::EULER as NativeFloat); + pub const GOLDEN_RATIO: SNumber = SNumber::Float(numbers::GOLDEN_RATIO as NativeFloat); + pub const GRAVITATIONAL_CONSTANT: SNumber = + SNumber::Float(numbers::GRAVITATIONAL_CONSTANT as NativeFloat); + pub const PI: SNumber = SNumber::Float(numbers::PI as NativeFloat); + pub const PLANCK: SNumber = SNumber::Float(numbers::PLANCK as NativeFloat); } pub trait NativeCasts { diff --git a/schemius/tests/sparse.rs b/schemius/tests/sparse.rs index f16b77f..ec8b89f 100644 --- a/schemius/tests/sparse.rs +++ b/schemius/tests/sparse.rs @@ -153,7 +153,8 @@ fn interpreter_binding() { fn interpreter_quasiquotation() { integration_subtest_eval_to! { { expression: "(define x '(1 2 3))", expected: "ok" }; - { expression: "`(,x 3 ,pi ,(list 1 2 3 4 5))", expected: "((1 2 3) 3 3.141592653589793 (1 2 3 4 5))" }; + { expression: "(define pi 3.14)", expected: "ok" }; + { expression: "`(,x 3 ,pi ,(list 1 2 3 4 5))", expected: "((1 2 3) 3 3.14 (1 2 3 4 5))" }; { expression: "`(,x ,x)", expected: "((1 2 3) (1 2 3))" }; { expression: "`(,@x ,@x)", expected: "(1 2 3 1 2 3)" }; { expression: "`(,x ,@x)", expected: "((1 2 3) 1 2 3)" };