diff --git a/__test__/satysrc/generic.saty b/__test__/satysrc/generic.saty index 3b2fdff..38da84d 100644 --- a/__test__/satysrc/generic.saty +++ b/__test__/satysrc/generic.saty @@ -37,16 +37,6 @@ @import: ../../src/tree-map @import: ../../src/big-int -let () = Debug.log `==== Promise ====` in -let p = Promise.delay ~(!!(&(let () = Debug.log `foo` in 1))) in -let () = Debug.log `bar` in -let _ = Promise.force p in -let _ = Promise.force p in -let p = Promise.delay ~(!!(&(let () = Debug.log `foobar` in 3.14))) in -let () = Debug.log `barbaz` in -let _ = Promise.force p in -let _ = Promise.force p in - let () = Debug.log `==== Float ====` in let p f = f |> String.of-float |> Debug.log in let () = p Float.pi in diff --git a/test/main.test.saty b/test/main.test.saty index af679dc..5ce72e1 100644 --- a/test/main.test.saty +++ b/test/main.test.saty @@ -13,6 +13,7 @@ @import: list.test @import: map.test @import: parser.test +@import: promise.test @import: ref.test @import: regex.test @import: string.test @@ -26,6 +27,7 @@ describe `base` [ list-test-cases; map-test-cases; parser-test-cases; + promise-test-cases; ref-test-cases; regex-test-cases; string-test-cases; diff --git a/test/promise.test.satyg b/test/promise.test.satyg new file mode 100644 index 0000000..7b0a12f --- /dev/null +++ b/test/promise.test.satyg @@ -0,0 +1,20 @@ +@require: test/test +@require: test/expect + +@import: ../src/base0 +@import: ../src/ref +@import: ../src/promise + +let promise-test-cases = open Test in + describe `Promise module` [ + it `evaluate lazily` (fun () -> ( + let r = Ref.make 0 in + let p = Promise.delay ~(!!(&(let () = r |> Ref.inc in 1))) in + Ref.get r == 0 + && (let _ = Promise.force p in + Ref.get r == 1 + && (let _ = Promise.force p in + Ref.get r == 1)) + |> Expect.is-true + )); + ]