Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Add test for operations with rationals
Browse files Browse the repository at this point in the history
  • Loading branch information
gavrilikhin-d committed Mar 3, 2024
1 parent b00f89c commit e682168
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/src/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions src/semantics/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/semantics/tests/rational/rational.ppl
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions src/semantics/tests/rational/run.log
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e682168

Please sign in to comment.