-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from git-afsantos/dev-v1.2
HPL v1.2.0
- Loading branch information
Showing
4 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Copyright © 2023 André Santos | ||
|
||
############################################################################### | ||
# Imports | ||
############################################################################### | ||
|
||
from hpl.ast.properties import HplProperty | ||
from hpl.parser import property_parser | ||
from hpl.rewrite import canonical_form | ||
|
||
############################################################################### | ||
# Predicate Examples | ||
############################################################################### | ||
|
||
|
||
############################################################################### | ||
# Test Code | ||
############################################################################### | ||
|
||
parser = property_parser() | ||
|
||
|
||
def test_canonical_global_absence_no_splits(): | ||
property = parser.parse('globally: no a') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 1 | ||
assert outputs[0] is property | ||
|
||
|
||
def test_canonical_global_absence_splits(): | ||
property = parser.parse('globally: no (a or b)') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 2 | ||
|
||
assert outputs[0].pattern.behaviour.is_simple_event | ||
assert outputs[1].pattern.behaviour.is_simple_event | ||
|
||
assert outputs[0].pattern.behaviour is property.pattern.behaviour.event1 | ||
assert outputs[1].pattern.behaviour is property.pattern.behaviour.event2 | ||
|
||
|
||
def test_canonical_global_existence_no_splits(): | ||
property = parser.parse('globally: some (a or b)') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 1 | ||
assert outputs[0] is property | ||
|
||
|
||
def test_canonical_after_existence_splits(): | ||
property = parser.parse('after (a or b): some (c or d)') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 2 | ||
|
||
assert outputs[0].scope.activator.is_simple_event | ||
assert outputs[1].scope.activator.is_simple_event | ||
|
||
assert outputs[0].scope.activator is property.scope.activator.event1 | ||
assert outputs[1].scope.activator is property.scope.activator.event2 | ||
|
||
assert outputs[0].pattern is property.pattern | ||
assert outputs[1].pattern is property.pattern | ||
|
||
|
||
def test_canonical_global_response_no_splits(): | ||
property = parser.parse('globally: a causes (b or c)') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 1 | ||
assert outputs[0] is property | ||
|
||
|
||
def test_canonical_global_response_splits(): | ||
property = parser.parse('globally: (a or b) causes (c or d)') | ||
outputs = canonical_form(property) | ||
|
||
assert len(outputs) == 2 | ||
|
||
assert outputs[0].pattern.trigger.is_simple_event | ||
assert outputs[1].pattern.trigger.is_simple_event | ||
|
||
assert outputs[0].pattern.trigger is property.pattern.trigger.event1 | ||
assert outputs[1].pattern.trigger is property.pattern.trigger.event2 |