Skip to content

Commit

Permalink
lit: Some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
volsa committed Jan 29, 2025
1 parent eca00f0 commit 2844a2c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lowering/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ mod tests {
use crate::{
lowering::property::PropertyLowerer,
resolver::AstAnnotations,
test_utils::tests::{annotate_with_ids, index_unit_with_id, index_with_ids, parse},
test_utils::tests::{annotate_with_ids, index_unit_with_id, parse},
};

#[test]
Expand Down
20 changes: 20 additions & 0 deletions tests/lit/single/property/called_inside_pou_where_defined.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: (%COMPILE %s && %RUN) | %CHECK %s

FUNCTION_BLOCK A
PROPERTY sayCheese : DINT
GET
printf('Cheese');
END_GET
END_PROPERTY

sayCheese;
END_FUNCTION_BLOCK

FUNCTION main
VAR
instanceA : A;
END_VAR

// CHECK: Cheese
instanceA();
END_FUNCTION
58 changes: 58 additions & 0 deletions tests/lit/single/property/multiply_properties_single_pou.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// RUN: (%COMPILE %s && %RUN) | %CHECK %s

FUNCTION_BLOCK A
VAR
foo : DINT;
END_VAR

PROPERTY increaseFooBy10 : DINT
GET
printf('Inside increaseFooBy10$N');
foo := foo + 10;
END_GET
END_PROPERTY

PROPERTY increaseFooBy20 : DINT
GET
printf('Inside increaseFooBy20$N');
foo := foo + 20;
END_GET
END_PROPERTY

PROPERTY increaseFooBy30 : DINT
GET
printf('Inside increaseFooBy30$N');
increaseFooBy20;
increaseFooBy10;
END_GET
END_PROPERTY

PROPERTY readFoo : DINT
GET
printf('Inside readFoo$N');
readFoo := foo;
END_GET
END_PROPERTY
END_FUNCTION_BLOCK

FUNCTION main
VAR
instanceA : A;
result : DINT;
END_VAR

// CHECK: Inside increaseFooBy10
instanceA.increaseFooBy10;

// CHECK: Inside increaseFooBy20
instanceA.increaseFooBy20;

// CHECK: Inside increaseFooBy30
// CHECK: Inside increaseFooBy20
// CHECK: Inside increaseFooBy10
instanceA.increaseFooBy30;

// CHECK: Inside readFoo
// CHECK: 60
printf('%d$N', instanceA.readFoo);
END_FUNCTION
2 changes: 1 addition & 1 deletion tests/lit/single/property/recursion.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Ignored for now
// RRRRRRRRRRRRRRRRRRRRRRUN: (%COMPILE %s && %RUN) | %CHECK %s
// NUR: (%COMPILE %s && %RUN) | %CHECK %s

FUNCTION_BLOCK A
PROPERTY foo : DINT
Expand Down

0 comments on commit 2844a2c

Please sign in to comment.