Skip to content

Commit 5a83824

Browse files
committed
Add more examples of async, attributes, and type abstractions.
1 parent 2c322b6 commit 5a83824

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

tests/syntax_tests/data/parsing/grammar/expressions/async.res

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ let ex1 = await 3 + await 4
3535
let ex2 = await 3 ** await 4
3636
let ex3 = await foo->bar(~arg)
3737
let ex4 = await foo.bar.baz
38+
39+
40+
let attr1 = @a async x => x+1
41+
let attr2 = @a async (type a) => (type b c, x) => 3
42+
let attr3 = @a (type a) => async (type b c, x) => 3
43+
let attr4 = @a (type a) => @b async (type b c, x) => 3
44+
let attr5 : int = @a @b async (type a, type b c) => (x:a) => x

tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@ let bar = ((fun [arity:1]~a:((a)[@res.namedArgLoc ]) -> a + 1)[@res.async ])
3131
let ex1 = ((3)[@res.await ]) + ((4)[@res.await ])
3232
let ex2 = ((3)[@res.await ]) ** ((4)[@res.await ])
3333
let ex3 = ((foo |.u (bar ~arg:((arg)[@res.namedArgLoc ])))[@res.await ])
34-
let ex4 = (((foo.bar).baz)[@res.await ])
34+
let ex4 = (((foo.bar).baz)[@res.await ])
35+
let attr1 = ((fun [arity:1]x -> x + 1)[@res.async ][@a ])
36+
let attr2 = ((fun (type a) -> fun (type b) -> fun (type c) ->
37+
fun [arity:1]x -> 3)[@res.async ][@a ])
38+
let attr3 = ((fun (type a) -> ((fun (type b) -> fun (type c) ->
39+
fun [arity:1]x -> 3)[@res.async ]))[@a ])
40+
let attr4 = ((fun (type a) -> ((fun (type b) -> fun (type c) ->
41+
fun [arity:1]x -> 3)[@res.async ][@b ]))[@a ])
42+
let (attr5 : int) = ((fun (type a) -> fun (type b) -> fun (type c) ->
43+
fun [arity:1](x : a) -> x)[@res.async ][@a ][@b ])

tests/syntax_tests/data/printer/expr/asyncAwait.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ type t2 = (. int, string) => bool
122122
let f = async (type a, ()) => {
123123
await Js.Promise.resolve(())
124124
}
125+
126+
let attr1 = @a async x => x+1
127+
let attr2 = @a async (type a) => (type b c, x) => 3
128+
let attr3 = @a (type a) => async (type b c, x) => 3
129+
let attr4 = @a (type a) => @b async (type b c, x) => 3
130+
let attr5 : int => promise<int> = @a @b async (type a, type b c) => (x:a) => x

tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ type t2 = (int, string) => bool
144144
let f = async (type a, ()) => {
145145
await Js.Promise.resolve()
146146
}
147+
148+
let attr1 = @a async x => x + 1
149+
let attr2 = @a async (type a b c, x) => 3
150+
let attr3 = @a (type a, type b c, x) => 3
151+
let attr4 = @a (type a, @b type b c, x) => 3
152+
let attr5: int => promise<int> = @a @b async (type a b c, x: a) => x

0 commit comments

Comments
 (0)