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 Rational and fix 3 / 2
Browse files Browse the repository at this point in the history
* Replace integers to rational in test

* Add test for operations with rationals
  • Loading branch information
gavrilikhin-d authored Mar 3, 2024
1 parent 1c77fc6 commit 8d0a547
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
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
8 changes: 4 additions & 4 deletions src/semantics/tests/plus_assign/plus_assign.ppl
Original file line number Diff line number Diff line change
@@ -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!"
Expand Down
4 changes: 2 additions & 2 deletions src/semantics/tests/plus_assign/run.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0
1
0.0
1.0
Hello World!
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 8d0a547

Please sign in to comment.