-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
631 additions
and
550 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
(env-data {"keyset": { "keys": ["bob"], "pred": "keys-any" }}) | ||
(env-keys ["bob"]) | ||
(begin-tx) | ||
(define-namespace 'free (read-keyset 'keyset) (read-keyset 'keyset)) | ||
(commit-tx) | ||
|
||
(begin-tx) | ||
(namespace 'free) | ||
(module modA G | ||
(defcap G () true) | ||
(defun func (x) (+ 1 x)) | ||
(defconst test:string "hi") | ||
) | ||
(module modB G | ||
(defcap G () true) | ||
(defun chain () (modA.func 10)) | ||
(defconst test:string "hello") | ||
(defun get-test() test) | ||
) | ||
|
||
(expect "ns-scoped module call works fully qualified" (free.modB.chain) 11) | ||
|
||
(namespace 'free) | ||
|
||
(expect "ns-scoped module call works within namespace scope" (modB.chain) 11) | ||
|
||
(expect "selects correct test" (modB.get-test) "hello") | ||
(commit-tx) | ||
|
||
; works across different txs | ||
(begin-tx) | ||
(namespace 'free) | ||
(module modA G | ||
(defcap G () true) | ||
(defun func (x) (+ 1 x)) | ||
(defconst test:string "hi") | ||
) | ||
(commit-tx) | ||
(begin-tx) | ||
(namespace 'free) | ||
(module modB G | ||
(defcap G () true) | ||
(defun chain () (modA.func 10)) | ||
(defconst test:string "hello") | ||
(defun get-test() test) | ||
) | ||
|
||
(expect "ns-scoped module call works fully qualified" (free.modB.chain) 11) | ||
|
||
(namespace 'free) | ||
|
||
(expect "ns-scoped module call works within namespace scope" (modB.chain) 11) | ||
|
||
(expect "selects correct test" (modB.get-test) "hello") | ||
(commit-tx) | ||
|
||
;; | ||
;; Module redeploy name resolution | ||
;; | ||
|
||
; In the following tests, we define a module `test-mod-redeploy-ref`, and then | ||
; redeploy the same module with the change to one capability: `test`. | ||
; In the old version, the `test` capability fails, in the new one it passes. | ||
|
||
(begin-tx) | ||
; First, demonstrate the behavior prior to pact-4.8. | ||
; (env-exec-config ["DisablePact48"]) | ||
|
||
(namespace 'free) | ||
(module test-mod-redeploy-ref g | ||
(defcap g () true) | ||
|
||
(defcap test () | ||
(enforce false "boom")) | ||
|
||
(defun f () | ||
(with-capability (test) | ||
1)) | ||
) | ||
; Before pact-4.8, the updated capability will be ignored, and calls to a function | ||
; requiring that capability will fail. | ||
(expect-failure "Demonstrate defcap resolution." (f)) | ||
|
||
(commit-tx) | ||
|
||
(begin-tx) | ||
(namespace 'free) | ||
(module test-mod-redeploy-ref g | ||
(defcap g () true) | ||
|
||
(defcap test () | ||
(enforce false "boom")) | ||
|
||
(defun f () | ||
(with-capability (test) | ||
1)) | ||
) | ||
(commit-tx) | ||
|
||
(begin-tx) | ||
(namespace 'free) | ||
(env-exec-config []) ; reset | ||
|
||
(module test-mod-redeploy-ref g | ||
(defcap g () true) | ||
(defcap test () | ||
true) | ||
(defun f () | ||
(with-capability (free.test-mod-redeploy-ref.test) | ||
1)) | ||
|
||
(defun f1 () | ||
(with-capability (test-mod-redeploy-ref.test) | ||
1)) | ||
) | ||
; These tests show that f now references the updated version of the capability. | ||
(expect "Demonstrate correct resolution with fully-qualified reference." 1 (f)) | ||
(expect "Demonstrate correct resolution with non-namespace-qualified reference." 1 (f1)) | ||
|
||
(commit-tx) |
Oops, something went wrong.