Skip to content

Commit

Permalink
Fix numerical constants for non-default floats
Browse files Browse the repository at this point in the history
  • Loading branch information
cowuake committed Aug 19, 2024
1 parent b9063ba commit 482de8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions schemius/src/core/s_expression/s_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion schemius/tests/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)" };
Expand Down

0 comments on commit 482de8d

Please sign in to comment.