Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1346, parsing of diff-time as property #1349

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src-tool/Pact/Analyze/Parse/Prop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ inferPreProp preProp = case preProp of
_ -> throwErrorIn b $
"expected integer or decimal, found " <> pretty (existentialType b')

PreApp s [a,b]
| s == STemporalDiff -> do
a' <- checkPreProp STime a
b' <- checkPreProp STime b
pure $ Some SDecimal $ CoreProp $ DiffTime a' b'

PreApp op'@(toOp comparisonOpP -> Just op) [a, b] -> do
a''@(Some aTy a') <- inferPreProp a
b''@(Some bTy b') <- inferPreProp b
Expand Down
9 changes: 9 additions & 0 deletions tests/AnalyzeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,15 @@ spec = describe "analyze" $ do
(diff-time (time "2021-01-01T00:00:01Z") (time "2021-01-01T00:00:00Z")))
|]
in expectVerified code
describe "diff-time implementation as property (#1346)" $
let code =
[text|
(defun test:decimal (a: time b: time)
@model[(property (> (diff-time a b) 0.0))]
(enforce (> (diff-time a b) 0.0) "a-b > 0")
1.0)
|]
in expectVerified code

describe "regression time representation (int64/integer)" $
let code =
Expand Down
Loading