@@ -7,7 +7,7 @@ let eq loc x y =
7
7
8
8
9
9
10
- open Js_promise2
10
+ open Js_promise
11
11
12
12
let assert_bool b =
13
13
if b then ()
@@ -20,12 +20,12 @@ let fail _ =
20
20
21
21
let thenTest () =
22
22
let p = resolve 4 in
23
- p |. then_ (fun x -> resolve @@ assert_bool (x = 4 ))
23
+ p |> then_ (fun x -> resolve @@ assert_bool (x = 4 ))
24
24
25
25
let andThenTest () =
26
26
let p = resolve 6 in
27
- p |. then_ (fun _ -> resolve (12 ))
28
- |. then_ (fun y -> resolve @@ assert_bool (y = 12 ))
27
+ p |> then_ (fun _ -> resolve (12 ))
28
+ |> then_ (fun y -> resolve @@ assert_bool (y = 12 ))
29
29
30
30
let h = resolve ()
31
31
@@ -38,66 +38,66 @@ let assertIsNotFound (x : Js_promise.error) =
38
38
(* * would be nice to have [%bs.open? Stack_overflow]*)
39
39
let catchTest () =
40
40
let p = reject Not_found in
41
- p |. then_ fail
42
- |. catch (fun error ->
41
+ p |> then_ fail
42
+ |> catch (fun error ->
43
43
assertIsNotFound error
44
44
)
45
45
46
46
let orResolvedTest () =
47
47
let p = resolve 42 in
48
- p |. catch (fun _ -> resolve 22 )
49
- |. then_ (fun value -> resolve @@ assert_bool (value = 42 ))
50
- |. catch fail
48
+ p |> catch (fun _ -> resolve 22 )
49
+ |> then_ (fun value -> resolve @@ assert_bool (value = 42 ))
50
+ |> catch fail
51
51
52
52
let orRejectedTest () =
53
53
let p = reject Not_found in
54
- p |. catch (fun _ -> resolve 22 )
55
- |. then_ (fun value -> resolve @@ assert_bool (value = 22 ))
56
- |. catch fail
54
+ p |> catch (fun _ -> resolve 22 )
55
+ |> then_ (fun value -> resolve @@ assert_bool (value = 22 ))
56
+ |> catch fail
57
57
58
58
let orElseResolvedTest () =
59
59
let p = resolve 42 in
60
- p |. catch (fun _ -> resolve 22 )
61
- |. then_ (fun value -> resolve @@ assert_bool (value = 42 ))
62
- |. catch fail
60
+ p |> catch (fun _ -> resolve 22 )
61
+ |> then_ (fun value -> resolve @@ assert_bool (value = 42 ))
62
+ |> catch fail
63
63
64
64
let orElseRejectedResolveTest () =
65
65
let p = reject Not_found in
66
- p |. catch (fun _ -> resolve 22 )
67
- |. then_ (fun value -> resolve @@ assert_bool (value = 22 ))
68
- |. catch fail
66
+ p |> catch (fun _ -> resolve 22 )
67
+ |> then_ (fun value -> resolve @@ assert_bool (value = 22 ))
68
+ |> catch fail
69
69
70
70
let orElseRejectedRejectTest () =
71
71
let p = reject Not_found in
72
- p |. catch (fun _ -> reject Stack_overflow )
73
- |. then_ fail
74
- |. catch (fun error ->
72
+ p |> catch (fun _ -> reject Stack_overflow )
73
+ |> then_ fail
74
+ |> catch (fun error ->
75
75
match (function [@ bs.open ] Stack_overflow -> 0 ) error with
76
76
| Some _ -> h
77
77
| None -> assert false
78
78
(* resolve @@ assert_bool (Obj.magic error == Stack_overflow) *) )
79
79
80
80
let resolveTest () =
81
81
let p1 = resolve 10 in
82
- p1 |. then_ (fun x -> resolve @@ assert_bool (x = 10 ))
82
+ p1 |> then_ (fun x -> resolve @@ assert_bool (x = 10 ))
83
83
84
84
let rejectTest () =
85
85
let p = reject Not_found in
86
- p |. catch
86
+ p |> catch
87
87
(fun error ->
88
88
assertIsNotFound error
89
89
(* resolve @@ assert_bool (Obj.magic error == Not_found) *)
90
90
)
91
91
92
92
let thenCatchChainResolvedTest () =
93
93
let p = resolve 20 in
94
- p |. then_ (fun value -> resolve @@ assert_bool (value = 20 ) )
95
- |. catch fail
94
+ p |> then_ (fun value -> resolve @@ assert_bool (value = 20 ) )
95
+ |> catch fail
96
96
97
97
let thenCatchChainRejectedTest () =
98
98
let p = reject Not_found in
99
- p |. then_ fail
100
- |. catch (fun error ->
99
+ p |> then_ fail
100
+ |> catch (fun error ->
101
101
assertIsNotFound error
102
102
(* resolve @@ assert_bool (Obj.magic error == Not_found) *) )
103
103
@@ -108,7 +108,7 @@ let allResolvedTest () =
108
108
let p3 = resolve 3 in
109
109
let promises = [| p1; p2; p3 |] in
110
110
all promises
111
- |. then_
111
+ |> then_
112
112
(fun resolved ->
113
113
assert_bool (resolved.(0 ) = 1 ) ;
114
114
assert_bool (resolved.(1 ) = 2 ) ;
@@ -123,26 +123,26 @@ let allRejectTest () =
123
123
let p3 = reject Not_found in
124
124
let promises = [| p1; p2; p3 |] in
125
125
all promises
126
- |. then_ fail
127
- |. catch (fun error -> assert_bool (Obj. magic error == Not_found ) ; h)
126
+ |> then_ fail
127
+ |> catch (fun error -> assert_bool (Obj. magic error == Not_found ) ; h)
128
128
129
129
let raceTest () =
130
130
let p1 = resolve " first" in
131
131
let p2 = resolve " second" in
132
132
let p3 = resolve " third" in
133
133
let promises = [| p1; p2; p3 |] in
134
134
race promises
135
- |. then_ (fun resolved -> h)
136
- |. catch fail
135
+ |> then_ (fun resolved -> h)
136
+ |> catch fail
137
137
138
138
let createPromiseRejectTest () =
139
139
make (fun ~resolve ~reject -> reject Not_found [@ bs])
140
- |. catch (fun error -> assert_bool (Obj. magic error == Not_found ); h)
140
+ |> catch (fun error -> assert_bool (Obj. magic error == Not_found ); h)
141
141
142
142
let createPromiseFulfillTest () =
143
143
make (fun ~resolve ~reject :_ -> resolve " success" [@ bs])
144
- |. then_ (fun resolved -> assert_bool (Obj. magic resolved = " success" ); h)
145
- |. catch fail
144
+ |> then_ (fun resolved -> assert_bool (Obj. magic resolved = " success" ); h)
145
+ |> catch fail
146
146
147
147
let () =
148
148
ignore @@ thenTest () ;
@@ -164,30 +164,30 @@ let () =
164
164
(* * TODO: async tests?
165
165
*)
166
166
let () =
167
- (Js.Promise2 . all2 (Js.Promise2 . resolve 2 , Js.Promise2 . resolve 3 ))
168
- |. Js.Promise2 . then_ (fun (a ,b ) ->
167
+ (Js.Promise . all2 (Js.Promise . resolve 2 , Js.Promise . resolve 3 ))
168
+ |> Js.Promise . then_ (fun (a ,b ) ->
169
169
eq __LOC__ (a,b) (2 ,3 );
170
170
171
- Js.Promise2 . resolve ()
171
+ Js.Promise . resolve ()
172
172
)
173
- |. ignore
173
+ |> ignore
174
174
175
175
176
176
;; Js. log (List. length ! suites)
177
177
178
178
;; Js. log " hey"
179
179
;; Mt. from_pair_suites __MODULE__ ! suites
180
180
181
- let twop = Js.Promise2 . resolve 2
182
- let then_ = Js.Promise2 . then_
183
- let re = Js.Promise2 . resolve
181
+ let twop = Js.Promise . resolve 2
182
+ let then_ = Js.Promise . then_
183
+ let re = Js.Promise . resolve
184
184
185
185
;; Mt. from_promise_suites __MODULE__
186
186
[
187
187
__LOC__,
188
188
twop
189
- |. then_ (fun x -> re @@ Mt. Eq (x,2 ));
189
+ |> then_ (fun x -> re @@ Mt. Eq (x,2 ));
190
190
__LOC__,
191
191
twop
192
- |. then_ (fun x -> re @@ Mt. Neq (x,3 ))
192
+ |> then_ (fun x -> re @@ Mt. Neq (x,3 ))
193
193
]
0 commit comments