Skip to content

Commit

Permalink
One more test
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Sep 6, 2024
1 parent 304866d commit 40b33d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion rust-semantics/expression/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module RUST-EXPRESSION-CALLS
<values> A |-> struct(TraitName:TypePath, _) ... </values>
requires isValueWithPtr(Args)
// TODO: Test for this.
rule methodCall
(... traitName: _TraitName:TypePath
, method: _MethodName:Identifier
Expand Down
7 changes: 7 additions & 0 deletions rust-semantics/test/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module RUST-EXECUTION-TEST-PARSING-SYNTAX
| "call" TypePath "." Identifier
| "return_value"
| "check_eq" Expression [strict]
| "push" Expression [strict]
endmodule
module RUST-EXECUTION-TEST
Expand Down Expand Up @@ -73,6 +74,12 @@ module RUST-EXECUTION-TEST
<k> check_eq ptrValue(_, V:Value) => .K ... </k>
<test-stack> ListItem(ptrValue(_, V)) => .List ... </test-stack>
rule
<k> push ptrValue(_, V:Value) => .K ... </k>
<test-stack> .List => ListItem(ptr(NVI)) ... </test-stack>
<values> VALUES:Map => VALUES[NVI <- V] </values>
<next-value-id> NVI:Int => NVI +Int 1 </next-value-id>
endmodule
```
6 changes: 6 additions & 0 deletions tests/execution/function-call.7.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
new FunctionCalls;
push 1_u64;
push 3_u64;
call FunctionCalls.call_arguments;
return_value;
check_eq 4_u64
7 changes: 7 additions & 0 deletions tests/execution/function-call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ pub trait FunctionCalls {
self.get_self().one()
}
fn get_self(&self) -> FunctionCalls { self }

fn call_arguments(&self, x: u64, y: &u64) -> u64 {
self.sum_arguments(x, y)
}
fn sum_arguments(&self, x: u64, y: &u64) -> u64 {
x + y
}
}

0 comments on commit 40b33d5

Please sign in to comment.