diff --git a/src/runtime/src/integer.rs b/src/runtime/src/integer.rs index c89a71c9..aceebfaa 100644 --- a/src/runtime/src/integer.rs +++ b/src/runtime/src/integer.rs @@ -100,7 +100,7 @@ pub extern "C" fn integer_slash_integer(x: *const Integer, y: *const Integer) -> let x = unsafe { x.as_ref().unwrap() }; let y = unsafe { y.as_ref().unwrap() }; - let boxed = Box::new(Rational::from(x / y)); + let boxed = Box::new(Rational::from(x) / y); Box::into_raw(boxed) } diff --git a/src/semantics/tests/mod.rs b/src/semantics/tests/mod.rs index 456d747a..a90eb044 100644 --- a/src/semantics/tests/mod.rs +++ b/src/semantics/tests/mod.rs @@ -19,6 +19,7 @@ e2e!(non_class_constructor); e2e!(plus_assign); e2e!(predeclare_function); e2e!(predeclare_vars); +e2e!(rational); e2e!(reference_mut); e2e!(references); e2e!(specify_variable_ty); diff --git a/src/semantics/tests/plus_assign/plus_assign.ppl b/src/semantics/tests/plus_assign/plus_assign.ppl index 92304287..43d49b1f 100644 --- a/src/semantics/tests/plus_assign/plus_assign.ppl +++ b/src/semantics/tests/plus_assign/plus_assign.ppl @@ -1,7 +1,7 @@ -let mut i = 0 -println i -i += 1 -println i +let mut value = 0.0 +println value +value += 1.0 +println value let mut str = "Hello" str += " World!" diff --git a/src/semantics/tests/plus_assign/run.log b/src/semantics/tests/plus_assign/run.log index 98fbd89b..bb79ff17 100644 --- a/src/semantics/tests/plus_assign/run.log +++ b/src/semantics/tests/plus_assign/run.log @@ -1,3 +1,3 @@ -0 -1 +0.0 +1.0 Hello World! diff --git a/src/semantics/tests/rational/rational.ppl b/src/semantics/tests/rational/rational.ppl new file mode 100644 index 00000000..6ee21134 --- /dev/null +++ b/src/semantics/tests/rational/rational.ppl @@ -0,0 +1,15 @@ +println 0.0 +println +1.0 +println -2.0 +println 1.0 + 2.0 +println 5.0 - 1.0 +println 2.5 * 2.0 +println 9.0 / (3 / 2) +println 0.0 == 0.0 +println 1.0 != 0.0 +println 0.0 < 1.0 +println 1.0 > 0.0 +println 0.0 <= 0.0 +println 0.0 <= 1.0 +println 0.0 >= 0.0 +println 1.0 >= 0.0 \ No newline at end of file diff --git a/src/semantics/tests/rational/run.log b/src/semantics/tests/rational/run.log new file mode 100644 index 00000000..af874bed --- /dev/null +++ b/src/semantics/tests/rational/run.log @@ -0,0 +1,15 @@ +0.0 +1.0 +-2.0 +3.0 +4.0 +5.0 +6.0 +true +true +true +true +true +true +true +true