lawspec 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -1
- package/NORMALIZATION-LICENSES.txt +296 -0
- package/README.md +13 -4
- package/api.mjs +0 -8
- package/bin/lawspec.mjs +114 -79
- package/build.json +99 -117
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -0
- package/doctor.mjs +14 -4
- package/examples/native-payments/clojure/lawspec.json +1 -1
- package/examples/native-payments/csharp/lawspec.json +1 -1
- package/examples/native-payments/elixir/lawspec.json +1 -1
- package/examples/native-payments/erlang/lawspec.json +1 -1
- package/examples/native-payments/fsharp/lawspec.json +1 -1
- package/examples/native-payments/gleam/lawspec.json +1 -1
- package/examples/native-payments/go/lawspec.json +1 -1
- package/examples/native-payments/groovy/lawspec.json +1 -1
- package/examples/native-payments/haskell/lawspec.json +1 -1
- package/examples/native-payments/java/lawspec.json +1 -1
- package/examples/native-payments/javascript/lawspec.json +1 -1
- package/examples/native-payments/kotlin/lawspec.json +1 -1
- package/examples/native-payments/prolog/lawspec.json +20 -0
- package/examples/native-payments/prolog/src/domain/payments.pl +23 -0
- package/examples/native-payments/prolog/tests/domain/payment_generators.pl +17 -0
- package/examples/native-payments/python/lawspec.json +1 -1
- package/examples/native-payments/rust/lawspec.json +1 -1
- package/examples/native-payments/scala/lawspec.json +1 -1
- package/examples/native-payments/swift/lawspec.json +1 -1
- package/examples/native-payments/typescript/lawspec.json +1 -1
- package/examples/packages/orders/lawspec.json +1 -1
- package/examples/packages/orders/orders.lawspec +27 -25
- package/examples/packages/shop-domain/src/domain.lawspec +15 -14
- package/examples/packages/shop-tax-1/src/api.lawspec +1 -0
- package/examples/packages/shop-tax-1/src/rates.lawspec +1 -0
- package/examples/packages/shop-tax-2/src/api.lawspec +1 -0
- package/examples/packages/shop-tax-2/src/rates.lawspec +1 -0
- package/examples/rc1/authorization-snapshots.lawspec +24 -23
- package/examples/rc1/banner-filenames.lawspec +7 -6
- package/examples/rc1/bit-codec.lawspec +12 -11
- package/examples/rc1/bounded-witness-search.lawspec +52 -45
- package/examples/rc1/conflicting-requirements.lawspec +8 -7
- package/examples/rc1/constructive-witnesses.lawspec +40 -33
- package/examples/rc1/documentary-review.lawspec +9 -8
- package/examples/rc1/empty-domains.lawspec +16 -15
- package/examples/rc1/finite-integer-domains.lawspec +24 -23
- package/examples/rc1/law-metadata.lawspec +6 -5
- package/examples/rc1/native-payments.lawspec +17 -16
- package/examples/rc1/nesting/rrr.lawspec +4 -3
- package/examples/rc1/nesting/rru.lawspec +7 -6
- package/examples/rc1/nesting/rur.lawspec +7 -6
- package/examples/rc1/nesting/ruu.lawspec +10 -9
- package/examples/rc1/nesting/urr.lawspec +7 -6
- package/examples/rc1/nesting/uru.lawspec +10 -9
- package/examples/rc1/nesting/uur.lawspec +10 -9
- package/examples/rc1/nesting/uuu.lawspec +13 -12
- package/examples/rc1/order-workflow.lawspec +18 -17
- package/examples/rc1/parcel-measurements.lawspec +14 -13
- package/examples/rc1/picture-records.lawspec +6 -5
- package/examples/rc1/picture-tuples.lawspec +6 -5
- package/examples/rc1/record-payloads.lawspec +12 -11
- package/examples/rc1/recursive-records.lawspec +11 -10
- package/examples/rc1/refund-conformance.lawspec +7 -6
- package/examples/rc1/refund-policy.lawspec +15 -14
- package/examples/rc1/requirement-composition.lawspec +26 -25
- package/examples/rc1/structural-records.lawspec +13 -12
- package/examples/rc1-authoring.lawspec +6 -5
- package/examples/specs/abilities.lawspec +67 -65
- package/examples/specs/ability_imports.lawspec +58 -57
- package/examples/specs/actors.lawspec +23 -22
- package/examples/specs/algebra.lawspec +142 -141
- package/examples/specs/approvals.lawspec +19 -18
- package/examples/specs/async_bindings.lawspec +10 -9
- package/examples/specs/async_fetch.lawspec +12 -11
- package/examples/specs/atoi_codec.lawspec +16 -15
- package/examples/specs/boolean_flags.lawspec +10 -9
- package/examples/specs/builtins.lawspec +73 -72
- package/examples/specs/canonical_url.lawspec +14 -13
- package/examples/specs/collections.lawspec +153 -154
- package/examples/specs/composition.lawspec +70 -66
- package/examples/specs/concurrent_collections.lawspec +8 -7
- package/examples/specs/consistency.lawspec +4 -3
- package/examples/specs/contracts.lawspec +80 -79
- package/examples/specs/crypto.lawspec +26 -25
- package/examples/specs/ctc.lawspec +148 -0
- package/examples/specs/currying.lawspec +32 -31
- package/examples/specs/data_types.lawspec +50 -49
- package/examples/specs/distribution.lawspec +57 -56
- package/examples/specs/domain_modeling.lawspec +68 -47
- package/examples/specs/durations.lawspec +39 -38
- package/examples/specs/equivalent.lawspec +25 -24
- package/examples/specs/failures.lawspec +64 -63
- package/examples/specs/finite_data.lawspec +32 -31
- package/examples/specs/flow_stack.lawspec +64 -63
- package/examples/specs/gadt_expressions.lawspec +50 -49
- package/examples/specs/generation.lawspec +115 -114
- package/examples/specs/handler_bindings.lawspec +42 -40
- package/examples/specs/handles.lawspec +2 -1
- package/examples/specs/harness.lawspec +45 -43
- package/examples/specs/harness_testing.lawspec +18 -13
- package/examples/specs/indexed_arithmetic.lawspec +401 -126
- package/examples/specs/indexed_families.lawspec +182 -66
- package/examples/specs/keywords.lawspec +22 -21
- package/examples/specs/limits.lawspec +7 -6
- package/examples/specs/list_contracts.lawspec +121 -120
- package/examples/specs/list_refinements.lawspec +43 -42
- package/examples/specs/lists.lawspec +45 -44
- package/examples/specs/matchers.lawspec +79 -78
- package/examples/specs/matching.lawspec +43 -42
- package/examples/specs/mixed_inputs.lawspec +25 -24
- package/examples/specs/models.lawspec +44 -43
- package/examples/specs/parse_port.lawspec +28 -27
- package/examples/specs/payments.lawspec +55 -54
- package/examples/specs/railway.lawspec +59 -58
- package/examples/specs/records.lawspec +149 -148
- package/examples/specs/records_inner.lawspec +5 -4
- package/examples/specs/recursive_refinements.lawspec +30 -29
- package/examples/specs/refined_definitions.lawspec +24 -23
- package/examples/specs/refinements.lawspec +58 -57
- package/examples/specs/resilience.lawspec +161 -160
- package/examples/specs/resources.lawspec +61 -60
- package/examples/specs/scalar_adapters.lawspec +60 -59
- package/examples/specs/scalar_catalog.lawspec +165 -164
- package/examples/specs/scalars.lawspec +78 -77
- package/examples/specs/scheduling_order.lawspec +8 -7
- package/examples/specs/scheduling_overlap.lawspec +5 -4
- package/examples/specs/sequences.lawspec +66 -65
- package/examples/specs/sessions.lawspec +13 -12
- package/examples/specs/slug.lawspec +16 -15
- package/examples/specs/sum_refinements.lawspec +42 -41
- package/examples/specs/tables.lawspec +29 -28
- package/examples/specs/total_functions.lawspec +71 -70
- package/examples/specs/workflows.lawspec +101 -100
- package/examples-command.mjs +7 -7
- package/explain.mjs +6 -4
- package/expression-presentation.mjs +8 -8
- package/files.mjs +1 -1
- package/index.d.ts +10 -528
- package/launcher.mjs +9 -2
- package/lsp.mjs +10 -6
- package/native-evidence.mjs +25 -12
- package/native-examples.mjs +3 -3
- package/package.json +2 -1
- package/starter-rc1.lawspec +6 -5
- package/starter.lawspec +16 -15
- package/templates.mjs +88 -5
- package/test-command.mjs +40 -4
- package/migrate.mjs +0 -135
- package/migration-bindings.mjs +0 -86
- package/migration-cases.mjs +0 -45
- package/migration-collections.mjs +0 -54
- package/migration-correspondence.mjs +0 -275
- package/migration-generation.mjs +0 -99
- package/migration-laws.mjs +0 -102
- package/migration-records.mjs +0 -166
- package/migration-source.mjs +0 -247
- package/migration-write.mjs +0 -156
|
@@ -33,12 +33,12 @@ end function
|
|
|
33
33
|
law "|emailPdfInvoice result| is
|
|
34
34
|
description:
|
|
35
35
|
"PDF invoices sent by email retain their file names."
|
|
36
|
-
end
|
|
36
|
+
end description
|
|
37
37
|
definition:
|
|
38
38
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
39
39
|
"invoice.pdf"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
40
|
+
end definition
|
|
41
|
+
end law
|
|
42
42
|
|
|
43
43
|
function emailPdfLetter (name of type Text) -> EmailDelivery is
|
|
44
44
|
EmailDelivery record{recipient = "accounts@example.com", document = (Letter
|
|
@@ -49,9 +49,10 @@ end function
|
|
|
49
49
|
law "|emailPdfLetter result| is
|
|
50
50
|
description:
|
|
51
51
|
"Letters have no invoice PDF file name."
|
|
52
|
-
end
|
|
52
|
+
end description
|
|
53
53
|
definition:
|
|
54
54
|
"|email invoice PDF file name| (emailPdfLetter "invoice.pdf") must be
|
|
55
55
|
Nothing
|
|
56
|
-
end
|
|
57
|
-
end
|
|
56
|
+
end definition
|
|
57
|
+
end law
|
|
58
|
+
end unit
|
|
@@ -37,12 +37,12 @@ end function
|
|
|
37
37
|
law "|emailPdfInvoice result| is
|
|
38
38
|
description:
|
|
39
39
|
"PDF invoices sent by email retain their file names."
|
|
40
|
-
end
|
|
40
|
+
end description
|
|
41
41
|
definition:
|
|
42
42
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
43
43
|
"invoice.pdf"
|
|
44
|
-
end
|
|
45
|
-
end
|
|
44
|
+
end definition
|
|
45
|
+
end law
|
|
46
46
|
|
|
47
47
|
function emailPlainTextInvoice (name of type Text) -> EmailDelivery is
|
|
48
48
|
EmailDelivery record{recipient = "accounts@example.com", document = (Invoice
|
|
@@ -53,12 +53,12 @@ end function
|
|
|
53
53
|
law "|emailPlainTextInvoice result| is
|
|
54
54
|
description:
|
|
55
55
|
"Plain-text invoices have no PDF file name."
|
|
56
|
-
end
|
|
56
|
+
end description
|
|
57
57
|
definition:
|
|
58
58
|
"|email invoice PDF file name| (emailPlainTextInvoice "invoice.pdf") must be
|
|
59
59
|
Nothing
|
|
60
|
-
end
|
|
61
|
-
end
|
|
60
|
+
end definition
|
|
61
|
+
end law
|
|
62
62
|
|
|
63
63
|
function emailPdfLetter (name of type Text) -> EmailDelivery is
|
|
64
64
|
EmailDelivery record{recipient = "accounts@example.com", document = (Letter
|
|
@@ -69,9 +69,10 @@ end function
|
|
|
69
69
|
law "|emailPdfLetter result| is
|
|
70
70
|
description:
|
|
71
71
|
"Letters have no invoice PDF file name."
|
|
72
|
-
end
|
|
72
|
+
end description
|
|
73
73
|
definition:
|
|
74
74
|
"|email invoice PDF file name| (emailPdfLetter "invoice.pdf") must be
|
|
75
75
|
Nothing
|
|
76
|
-
end
|
|
77
|
-
end
|
|
76
|
+
end definition
|
|
77
|
+
end law
|
|
78
|
+
end unit
|
|
@@ -29,12 +29,12 @@ end function
|
|
|
29
29
|
law "|emailPdfInvoice result| is
|
|
30
30
|
description:
|
|
31
31
|
"PDF invoices sent by email retain their file names."
|
|
32
|
-
end
|
|
32
|
+
end description
|
|
33
33
|
definition:
|
|
34
34
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
35
35
|
"invoice.pdf"
|
|
36
|
-
end
|
|
37
|
-
end
|
|
36
|
+
end definition
|
|
37
|
+
end law
|
|
38
38
|
|
|
39
39
|
function downloadPdfInvoice (name of type Text) -> Delivery is
|
|
40
40
|
Download (record{document = record{number =
|
|
@@ -44,9 +44,10 @@ end function
|
|
|
44
44
|
law "|downloadPdfInvoice result| is
|
|
45
45
|
description:
|
|
46
46
|
"Downloads have no email invoice PDF file name."
|
|
47
|
-
end
|
|
47
|
+
end description
|
|
48
48
|
definition:
|
|
49
49
|
"|email invoice PDF file name| (downloadPdfInvoice "invoice.pdf") must be
|
|
50
50
|
Nothing
|
|
51
|
-
end
|
|
52
|
-
end
|
|
51
|
+
end definition
|
|
52
|
+
end law
|
|
53
|
+
end unit
|
|
@@ -32,12 +32,12 @@ end function
|
|
|
32
32
|
law "|emailPdfInvoice result| is
|
|
33
33
|
description:
|
|
34
34
|
"PDF invoices sent by email retain their file names."
|
|
35
|
-
end
|
|
35
|
+
end description
|
|
36
36
|
definition:
|
|
37
37
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
38
38
|
"invoice.pdf"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
39
|
+
end definition
|
|
40
|
+
end law
|
|
41
41
|
|
|
42
42
|
function emailPlainTextInvoice (name of type Text) -> Delivery is
|
|
43
43
|
Email (record{recipient = "accounts@example.com", document =
|
|
@@ -48,12 +48,12 @@ end function
|
|
|
48
48
|
law "|emailPlainTextInvoice result| is
|
|
49
49
|
description:
|
|
50
50
|
"Plain-text invoices have no PDF file name."
|
|
51
|
-
end
|
|
51
|
+
end description
|
|
52
52
|
definition:
|
|
53
53
|
"|email invoice PDF file name| (emailPlainTextInvoice "invoice.pdf") must be
|
|
54
54
|
Nothing
|
|
55
|
-
end
|
|
56
|
-
end
|
|
55
|
+
end definition
|
|
56
|
+
end law
|
|
57
57
|
|
|
58
58
|
function downloadPdfInvoice (name of type Text) -> Delivery is
|
|
59
59
|
Download (record{document = record{number =
|
|
@@ -64,9 +64,10 @@ end function
|
|
|
64
64
|
law "|downloadPdfInvoice result| is
|
|
65
65
|
description:
|
|
66
66
|
"Downloads have no email invoice PDF file name."
|
|
67
|
-
end
|
|
67
|
+
end description
|
|
68
68
|
definition:
|
|
69
69
|
"|email invoice PDF file name| (downloadPdfInvoice "invoice.pdf") must be
|
|
70
70
|
Nothing
|
|
71
|
-
end
|
|
72
|
-
end
|
|
71
|
+
end definition
|
|
72
|
+
end law
|
|
73
|
+
end unit
|
|
@@ -33,12 +33,12 @@ end function
|
|
|
33
33
|
law "|emailPdfInvoice result| is
|
|
34
34
|
description:
|
|
35
35
|
"PDF invoices sent by email retain their file names."
|
|
36
|
-
end
|
|
36
|
+
end description
|
|
37
37
|
definition:
|
|
38
38
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
39
39
|
"invoice.pdf"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
40
|
+
end definition
|
|
41
|
+
end law
|
|
42
42
|
|
|
43
43
|
function emailPdfLetter (name of type Text) -> Delivery is
|
|
44
44
|
Email (record{recipient = "accounts@example.com", document =
|
|
@@ -49,12 +49,12 @@ end function
|
|
|
49
49
|
law "|emailPdfLetter result| is
|
|
50
50
|
description:
|
|
51
51
|
"Letters have no invoice PDF file name."
|
|
52
|
-
end
|
|
52
|
+
end description
|
|
53
53
|
definition:
|
|
54
54
|
"|email invoice PDF file name| (emailPdfLetter "invoice.pdf") must be
|
|
55
55
|
Nothing
|
|
56
|
-
end
|
|
57
|
-
end
|
|
56
|
+
end definition
|
|
57
|
+
end law
|
|
58
58
|
|
|
59
59
|
function downloadPdfInvoice (name of type Text) -> Delivery is
|
|
60
60
|
Download (record{document = (Invoice (record{number = "INV-2026-10", file =
|
|
@@ -65,9 +65,10 @@ end function
|
|
|
65
65
|
law "|downloadPdfInvoice result| is
|
|
66
66
|
description:
|
|
67
67
|
"Downloads have no email invoice PDF file name."
|
|
68
|
-
end
|
|
68
|
+
end description
|
|
69
69
|
definition:
|
|
70
70
|
"|email invoice PDF file name| (downloadPdfInvoice "invoice.pdf") must be
|
|
71
71
|
Nothing
|
|
72
|
-
end
|
|
73
|
-
end
|
|
72
|
+
end definition
|
|
73
|
+
end law
|
|
74
|
+
end unit
|
|
@@ -38,12 +38,12 @@ end function
|
|
|
38
38
|
law "|emailPdfInvoice result| is
|
|
39
39
|
description:
|
|
40
40
|
"PDF invoices sent by email retain their file names."
|
|
41
|
-
end
|
|
41
|
+
end description
|
|
42
42
|
definition:
|
|
43
43
|
"|email invoice PDF file name| (emailPdfInvoice "invoice.pdf") must be Just
|
|
44
44
|
"invoice.pdf"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
45
|
+
end definition
|
|
46
|
+
end law
|
|
47
47
|
|
|
48
48
|
function emailPlainTextInvoice (name of type Text) -> Delivery is
|
|
49
49
|
Email (record{recipient = "accounts@example.com", document =
|
|
@@ -54,12 +54,12 @@ end function
|
|
|
54
54
|
law "|emailPlainTextInvoice result| is
|
|
55
55
|
description:
|
|
56
56
|
"Plain-text invoices have no PDF file name."
|
|
57
|
-
end
|
|
57
|
+
end description
|
|
58
58
|
definition:
|
|
59
59
|
"|email invoice PDF file name| (emailPlainTextInvoice "invoice.pdf") must be
|
|
60
60
|
Nothing
|
|
61
|
-
end
|
|
62
|
-
end
|
|
61
|
+
end definition
|
|
62
|
+
end law
|
|
63
63
|
|
|
64
64
|
function emailPdfLetter (name of type Text) -> Delivery is
|
|
65
65
|
Email (record{recipient = "accounts@example.com", document =
|
|
@@ -70,12 +70,12 @@ end function
|
|
|
70
70
|
law "|emailPdfLetter result| is
|
|
71
71
|
description:
|
|
72
72
|
"Letters have no invoice PDF file name."
|
|
73
|
-
end
|
|
73
|
+
end description
|
|
74
74
|
definition:
|
|
75
75
|
"|email invoice PDF file name| (emailPdfLetter "invoice.pdf") must be
|
|
76
76
|
Nothing
|
|
77
|
-
end
|
|
78
|
-
end
|
|
77
|
+
end definition
|
|
78
|
+
end law
|
|
79
79
|
|
|
80
80
|
function downloadPdfInvoice (name of type Text) -> Delivery is
|
|
81
81
|
Download (record{document = (Invoice (record{number = "INV-2026-10", file =
|
|
@@ -87,9 +87,10 @@ end function
|
|
|
87
87
|
law "|downloadPdfInvoice result| is
|
|
88
88
|
description:
|
|
89
89
|
"Downloads have no email invoice PDF file name."
|
|
90
|
-
end
|
|
90
|
+
end description
|
|
91
91
|
definition:
|
|
92
92
|
"|email invoice PDF file name| (downloadPdfInvoice "invoice.pdf") must be
|
|
93
93
|
Nothing
|
|
94
|
-
end
|
|
95
|
-
end
|
|
94
|
+
end definition
|
|
95
|
+
end law
|
|
96
|
+
end unit
|
|
@@ -28,17 +28,17 @@ end function
|
|
|
28
28
|
ability OrderStore is
|
|
29
29
|
current of type OrderState
|
|
30
30
|
change of type OrderState -> ()
|
|
31
|
-
end
|
|
31
|
+
end ability
|
|
32
32
|
|
|
33
33
|
handler inMemory for OrderStore with state order of type OrderState
|
|
34
34
|
start Pending is
|
|
35
|
-
current is order end
|
|
36
|
-
change updated is ~order := updated; () end
|
|
37
|
-
end
|
|
35
|
+
operation current is order end operation
|
|
36
|
+
operation change updated is ~order := updated; () end operation
|
|
37
|
+
end handler
|
|
38
38
|
|
|
39
39
|
procedure perform (action of type OrderAction) -> OrderState uses OrderStore is
|
|
40
40
|
let updated = nextState current action in
|
|
41
|
-
change updated; current
|
|
41
|
+
change updated; current end let
|
|
42
42
|
end procedure
|
|
43
43
|
|
|
44
44
|
procedure process (actions of type List OrderAction) -> OrderState
|
|
@@ -51,7 +51,7 @@ procedure process (actions of type List OrderAction) -> OrderState
|
|
|
51
51
|
end procedure
|
|
52
52
|
|
|
53
53
|
function runOrder (actions of type List OrderAction) -> OrderState is
|
|
54
|
-
handle process actions with inMemory end
|
|
54
|
+
handle process actions with inMemory end handle
|
|
55
55
|
end function
|
|
56
56
|
|
|
57
57
|
function modelRun (state of type OrderState)
|
|
@@ -78,8 +78,8 @@ law "|order transitions follow the business lifecycle| is
|
|
|
78
78
|
nextState state action must be Shipped)
|
|
79
79
|
and ((state = Pending or state = Authorized) and action = Cancel implies
|
|
80
80
|
nextState state action must be Cancelled)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
81
|
+
end for all
|
|
82
|
+
end definition
|
|
83
83
|
expect nextState state action = expected
|
|
84
84
|
in table (state, action, expected):
|
|
85
85
|
row Pending, Authorize, Authorized
|
|
@@ -94,18 +94,18 @@ law "|order transitions follow the business lifecycle| is
|
|
|
94
94
|
row Cancelled, Authorize, Cancelled
|
|
95
95
|
row Cancelled, Dispatch, Cancelled
|
|
96
96
|
row Cancelled, Cancel, Cancelled
|
|
97
|
-
end
|
|
98
|
-
end
|
|
97
|
+
end table
|
|
98
|
+
end law
|
|
99
99
|
|
|
100
100
|
law "|processing retains each completed transition| is
|
|
101
101
|
description:
|
|
102
102
|
"Every action observes the state left by the previous action."
|
|
103
|
-
end
|
|
103
|
+
end description
|
|
104
104
|
definition:
|
|
105
105
|
for all (actions of type List OrderAction) =>
|
|
106
106
|
runOrder actions must be modelRun Pending actions
|
|
107
|
-
end
|
|
108
|
-
end
|
|
107
|
+
end for all
|
|
108
|
+
end definition
|
|
109
109
|
expect runOrder actions = expected
|
|
110
110
|
in table (actions, expected):
|
|
111
111
|
row [], Pending
|
|
@@ -116,11 +116,12 @@ law "|processing retains each completed transition| is
|
|
|
116
116
|
row [Authorize, Cancel, Dispatch], Cancelled
|
|
117
117
|
row [Authorize, Dispatch, Cancel], Shipped
|
|
118
118
|
row [Authorize, Dispatch, Authorize], Shipped
|
|
119
|
-
end
|
|
120
|
-
end
|
|
119
|
+
end table
|
|
120
|
+
end law
|
|
121
121
|
|
|
122
122
|
law "|independent orders start pending| is
|
|
123
123
|
definition:
|
|
124
124
|
runOrder [Authorize] must be Authorized and runOrder [] must be Pending
|
|
125
|
-
end
|
|
126
|
-
end
|
|
125
|
+
end definition
|
|
126
|
+
end law
|
|
127
|
+
end unit
|
|
@@ -44,42 +44,42 @@ end function
|
|
|
44
44
|
law sampleWeight is
|
|
45
45
|
description:
|
|
46
46
|
"A sample parcel weighs one gram."
|
|
47
|
-
end
|
|
47
|
+
end description
|
|
48
48
|
definition:
|
|
49
49
|
sampleParcel () must be Parcel record{details = record{
|
|
50
50
|
weight = Measurement record{reading = record{value = 1}}
|
|
51
51
|
}}
|
|
52
|
-
end
|
|
53
|
-
end
|
|
52
|
+
end definition
|
|
53
|
+
end law
|
|
54
54
|
|
|
55
55
|
law positiveWeights is
|
|
56
56
|
description:
|
|
57
57
|
"Every accepted parcel measurement has a positive weight."
|
|
58
|
-
end
|
|
58
|
+
end description
|
|
59
59
|
definition:
|
|
60
60
|
for all (parcel of type record{
|
|
61
61
|
weight of type (measurement of type Measurement Integer
|
|
62
62
|
where measurement.reading.value > 0)
|
|
63
63
|
}) =>
|
|
64
64
|
weightOf parcel > 0
|
|
65
|
-
end
|
|
66
|
-
end
|
|
65
|
+
end for all
|
|
66
|
+
end definition
|
|
67
67
|
expect weightOf parcel = expected
|
|
68
68
|
in table (parcel, expected):
|
|
69
69
|
row record{weight = Measurement record{reading = record{value = 1}}}, 1
|
|
70
70
|
row record{weight = Measurement record{reading = record{value = 3}}}, 3
|
|
71
|
-
end
|
|
72
|
-
end
|
|
71
|
+
end table
|
|
72
|
+
end law
|
|
73
73
|
|
|
74
74
|
law recipientLabels is
|
|
75
75
|
description:
|
|
76
76
|
"Deliveries preserve the recipient written on their label."
|
|
77
|
-
end
|
|
77
|
+
end description
|
|
78
78
|
definition:
|
|
79
79
|
for all (delivery of type Delivery DeliveryLabel) =>
|
|
80
80
|
recipient delivery = recipient delivery
|
|
81
|
-
end
|
|
82
|
-
end
|
|
81
|
+
end for all
|
|
82
|
+
end definition
|
|
83
83
|
expect recipient delivery = expected
|
|
84
84
|
in table (delivery, expected):
|
|
85
85
|
row Delivery record{contents = record{value = DeliveryLabel record{
|
|
@@ -88,5 +88,6 @@ law recipientLabels is
|
|
|
88
88
|
row Delivery record{contents = record{value = DeliveryLabel record{
|
|
89
89
|
code = 8, recipient = "Bo"
|
|
90
90
|
}}}, "Bo"
|
|
91
|
-
end
|
|
92
|
-
end
|
|
91
|
+
end table
|
|
92
|
+
end law
|
|
93
|
+
end unit
|
|
@@ -28,7 +28,7 @@ end function
|
|
|
28
28
|
law "|named dimensions determine orientation| is
|
|
29
29
|
description:
|
|
30
30
|
"Dimension labels preserve their meaning in either field order."
|
|
31
|
-
end
|
|
31
|
+
end description
|
|
32
32
|
definition:
|
|
33
33
|
for all (picture of type Picture) =>
|
|
34
34
|
orientation picture must be
|
|
@@ -37,8 +37,8 @@ law "|named dimensions determine orientation| is
|
|
|
37
37
|
else Square
|
|
38
38
|
end if
|
|
39
39
|
end if
|
|
40
|
-
end
|
|
41
|
-
end
|
|
40
|
+
end for all
|
|
41
|
+
end definition
|
|
42
42
|
expect orientation picture = expected
|
|
43
43
|
in table (picture, expected):
|
|
44
44
|
row Picture record{fileName = "wide.jpg", dimensions = record{width = 12,
|
|
@@ -47,5 +47,6 @@ law "|named dimensions determine orientation| is
|
|
|
47
47
|
width = 8}}, Portrait
|
|
48
48
|
row Picture record{fileName = "square.jpg", dimensions = record{width = 10,
|
|
49
49
|
height = 10}}, Square
|
|
50
|
-
end
|
|
51
|
-
end
|
|
50
|
+
end table
|
|
51
|
+
end law
|
|
52
|
+
end unit
|
|
@@ -24,7 +24,7 @@ end function
|
|
|
24
24
|
law "|tuple dimensions determine orientation| is
|
|
25
25
|
description:
|
|
26
26
|
"Width comes first and height second in a picture's dimensions."
|
|
27
|
-
end
|
|
27
|
+
end description
|
|
28
28
|
definition:
|
|
29
29
|
for all (picture of type Picture) =>
|
|
30
30
|
orientation picture must be
|
|
@@ -36,12 +36,13 @@ law "|tuple dimensions determine orientation| is
|
|
|
36
36
|
end if
|
|
37
37
|
end if
|
|
38
38
|
end case
|
|
39
|
-
end
|
|
40
|
-
end
|
|
39
|
+
end for all
|
|
40
|
+
end definition
|
|
41
41
|
expect orientation picture = expected
|
|
42
42
|
in table (picture, expected):
|
|
43
43
|
row Picture record{fileName = "wide.jpg", dimensions = (12, 8)}, Landscape
|
|
44
44
|
row Picture record{fileName = "tall.jpg", dimensions = (8, 12)}, Portrait
|
|
45
45
|
row Picture record{fileName = "square.jpg", dimensions = (10, 10)}, Square
|
|
46
|
-
end
|
|
47
|
-
end
|
|
46
|
+
end table
|
|
47
|
+
end law
|
|
48
|
+
end unit
|
|
@@ -28,29 +28,30 @@ function boxedPayload (box of type Box a) -> record{value of type a} is
|
|
|
28
28
|
law pictureWidth is definition:
|
|
29
29
|
width (Picture record{fileName = "photo", dimensions = record{height = 3,
|
|
30
30
|
width = 2}}) must be 2
|
|
31
|
-
end end
|
|
31
|
+
end definition end law
|
|
32
32
|
law downloadLabel is definition: label (Download record{document = "paper"})
|
|
33
|
-
must be "paper" end end
|
|
33
|
+
must be "paper" end definition end law
|
|
34
34
|
law wrappedText is definition: extract (Envelope record{payload = record{value =
|
|
35
|
-
"note", copy = "other"}}) must be "note" end end
|
|
35
|
+
"note", copy = "other"}}) must be "note" end definition end law
|
|
36
36
|
law wrappedBoolean is definition: extract (Envelope record{payload =
|
|
37
|
-
record{value = true, copy = false}}) must be true end end
|
|
37
|
+
record{value = true, copy = false}}) must be true end definition end law
|
|
38
38
|
law wholeRecord is definition: unpack (Envelope record{payload = record{value =
|
|
39
|
-
true, copy = false}}) = record{copy = false, value = true} end end
|
|
39
|
+
true, copy = false}}) = record{copy = false, value = true} end definition end law
|
|
40
40
|
law boxedResult is definition: boxedPayload (Box record{value = true}) =
|
|
41
|
-
record{value = true} end end
|
|
41
|
+
record{value = true} end definition end law
|
|
42
42
|
law boxedRows is definition: for all (box of type Box Text) => boxedPayload box
|
|
43
|
-
= boxedPayload box end end
|
|
43
|
+
= boxedPayload box end for all end definition
|
|
44
44
|
expect (boxedPayload box).value = expected in table (box, expected):
|
|
45
45
|
row Box record{value = "note"}, "note"
|
|
46
46
|
row Box record{value = "paper"}, "paper"
|
|
47
|
-
end end
|
|
47
|
+
end table end law
|
|
48
48
|
law labels is
|
|
49
49
|
definition: for all (delivery of type Delivery) => label delivery = label
|
|
50
|
-
delivery end end
|
|
50
|
+
delivery end for all end definition
|
|
51
51
|
expect label delivery = expected
|
|
52
52
|
in table (delivery, expected):
|
|
53
53
|
row Download record{document = "paper"}, "paper"
|
|
54
54
|
row Unavailable, "unavailable"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
55
|
+
end table
|
|
56
|
+
end law
|
|
57
|
+
end unit
|
|
@@ -35,23 +35,23 @@ law "|an unissued approval has no finite construction| is
|
|
|
35
35
|
definition:
|
|
36
36
|
for all (approval of type UnissuedApproval) =>
|
|
37
37
|
false
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
38
|
+
end for all
|
|
39
|
+
end definition
|
|
40
|
+
end law
|
|
41
41
|
|
|
42
42
|
law "|mutually dependent snapshots have no first value| is
|
|
43
43
|
definition:
|
|
44
44
|
for all (snapshot of type FirstSnapshot) =>
|
|
45
45
|
false
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
46
|
+
end for all
|
|
47
|
+
end definition
|
|
48
|
+
end law
|
|
49
49
|
|
|
50
50
|
law "|a completed chain has no remaining approval| is
|
|
51
51
|
definition:
|
|
52
52
|
chainLength (ApprovalChain record{next = Nothing}) must be 0
|
|
53
|
-
end
|
|
54
|
-
end
|
|
53
|
+
end definition
|
|
54
|
+
end law
|
|
55
55
|
|
|
56
56
|
law "|a pending chain counts each remaining approval| is
|
|
57
57
|
definition:
|
|
@@ -60,5 +60,6 @@ law "|a pending chain counts each remaining approval| is
|
|
|
60
60
|
next = Just (ApprovalChain record{next = Nothing})
|
|
61
61
|
})
|
|
62
62
|
}) must be 2
|
|
63
|
-
end
|
|
64
|
-
end
|
|
63
|
+
end definition
|
|
64
|
+
end law
|
|
65
|
+
end unit
|
|
@@ -7,16 +7,16 @@ nativeRefund of type policy.RefundRequest -> policy.RefundDecision
|
|
|
7
7
|
law "|native refunds conform to the policy| is
|
|
8
8
|
description:
|
|
9
9
|
"The application's refund decision agrees with the checked policy."
|
|
10
|
-
end
|
|
10
|
+
end description
|
|
11
11
|
definition:
|
|
12
12
|
for all (request of type policy.RefundRequest) =>
|
|
13
13
|
nativeRefund request must be policy.refund request
|
|
14
|
-
end
|
|
15
|
-
end
|
|
14
|
+
end for all
|
|
15
|
+
end definition
|
|
16
16
|
|
|
17
17
|
references:
|
|
18
18
|
ref function policy.refund
|
|
19
|
-
end
|
|
19
|
+
end references
|
|
20
20
|
|
|
21
21
|
expect nativeRefund request = expected
|
|
22
22
|
in table (request, expected):
|
|
@@ -40,5 +40,6 @@ law "|native refunds conform to the policy| is
|
|
|
40
40
|
flagged = false}, policy.Approved
|
|
41
41
|
row policy.RefundRequest record{capturedAmount = 9007199254740992,
|
|
42
42
|
requestedAmount = 9007199254740993, flagged = false}, policy.Rejected
|
|
43
|
-
end
|
|
44
|
-
end
|
|
43
|
+
end table
|
|
44
|
+
end law
|
|
45
|
+
end unit
|
|
@@ -25,24 +25,24 @@ end function
|
|
|
25
25
|
law "|a zero refund is approved| is
|
|
26
26
|
description:
|
|
27
27
|
"A zero request transfers nothing and needs no review."
|
|
28
|
-
end
|
|
28
|
+
end description
|
|
29
29
|
definition:
|
|
30
30
|
for all (capturedAmount of type Whole) (flagged of type Bool) =>
|
|
31
31
|
refund (RefundRequest record{
|
|
32
32
|
capturedAmount = capturedAmount, requestedAmount = 0, flagged = flagged
|
|
33
33
|
}) must be Approved
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
34
|
+
end for all
|
|
35
|
+
end definition
|
|
36
|
+
end law
|
|
37
37
|
|
|
38
38
|
law "|a refund cannot exceed the captured amount| is
|
|
39
39
|
definition:
|
|
40
40
|
for all (request of type RefundRequest) =>
|
|
41
41
|
request.requestedAmount > request.capturedAmount implies
|
|
42
42
|
refund request must be Rejected
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
43
|
+
end for all
|
|
44
|
+
end definition
|
|
45
|
+
end law
|
|
46
46
|
|
|
47
47
|
law "|an eligible flagged refund requires review| is
|
|
48
48
|
definition:
|
|
@@ -50,17 +50,17 @@ law "|an eligible flagged refund requires review| is
|
|
|
50
50
|
request.requestedAmount > 0 and
|
|
51
51
|
request.requestedAmount <= request.capturedAmount and request.flagged
|
|
52
52
|
implies refund request must be ReviewRequired
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
53
|
+
end for all
|
|
54
|
+
end definition
|
|
55
|
+
end law
|
|
56
56
|
|
|
57
57
|
law "|an eligible unflagged refund is approved| is
|
|
58
58
|
definition:
|
|
59
59
|
for all (request of type RefundRequest) =>
|
|
60
60
|
request.requestedAmount <= request.capturedAmount and not request.flagged
|
|
61
61
|
implies refund request must be Approved
|
|
62
|
-
end
|
|
63
|
-
end
|
|
62
|
+
end for all
|
|
63
|
+
end definition
|
|
64
64
|
|
|
65
65
|
expect refund request = expected
|
|
66
66
|
in table (request, expected):
|
|
@@ -84,5 +84,6 @@ law "|an eligible unflagged refund is approved| is
|
|
|
84
84
|
= false}, Approved
|
|
85
85
|
row RefundRequest record{capturedAmount = 9007199254740992, requestedAmount
|
|
86
86
|
= 9007199254740993, flagged = false}, Rejected
|
|
87
|
-
end
|
|
88
|
-
end
|
|
87
|
+
end table
|
|
88
|
+
end law
|
|
89
|
+
end unit
|