mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Add more snapshot tests
This commit is contained in:
parent
0129e34275
commit
55f04a0688
2 changed files with 147 additions and 0 deletions
84
test/snapshots/statement/dbg_as_arg.md
Normal file
84
test/snapshots/statement/dbg_as_arg.md
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Debug as function argument
|
||||
type=snippet
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
foo = |f| f(dbg 42)
|
||||
bar = |f| f(dbg(42))
|
||||
~~~
|
||||
# EXPECTED
|
||||
NIL
|
||||
# PROBLEMS
|
||||
NIL
|
||||
# TOKENS
|
||||
~~~zig
|
||||
LowerIdent,OpAssign,OpBar,LowerIdent,OpBar,LowerIdent,NoSpaceOpenRound,KwDbg,Int,CloseRound,
|
||||
LowerIdent,OpAssign,OpBar,LowerIdent,OpBar,LowerIdent,NoSpaceOpenRound,KwDbg,NoSpaceOpenRound,Int,CloseRound,CloseRound,
|
||||
EndOfFile,
|
||||
~~~
|
||||
# PARSE
|
||||
~~~clojure
|
||||
(file
|
||||
(type-module)
|
||||
(statements
|
||||
(s-decl
|
||||
(p-ident (raw "foo"))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-ident (raw "f")))
|
||||
(e-apply
|
||||
(e-ident (raw "f"))
|
||||
(e-dbg
|
||||
(e-int (raw "42"))))))
|
||||
(s-decl
|
||||
(p-ident (raw "bar"))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-ident (raw "f")))
|
||||
(e-apply
|
||||
(e-ident (raw "f"))
|
||||
(e-dbg
|
||||
(e-tuple
|
||||
(e-int (raw "42")))))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
foo = |f| f(dbg 42)
|
||||
bar = |f| f(dbg (42))
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(d-let
|
||||
(p-assign (ident "foo"))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-assign (ident "f")))
|
||||
(e-call
|
||||
(e-lookup-local
|
||||
(p-assign (ident "f")))
|
||||
(e-dbg
|
||||
(e-num (value "42"))))))
|
||||
(d-let
|
||||
(p-assign (ident "bar"))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-assign (ident "f")))
|
||||
(e-call
|
||||
(e-lookup-local
|
||||
(p-assign (ident "f")))
|
||||
(e-dbg
|
||||
(e-num (value "42")))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt (type "({} -> a) => a"))
|
||||
(patt (type "({} -> a) => a")))
|
||||
(expressions
|
||||
(expr (type "({} -> a) => a"))
|
||||
(expr (type "({} -> a) => a"))))
|
||||
~~~
|
||||
63
test/snapshots/statement/dbg_last_in_block.md
Normal file
63
test/snapshots/statement/dbg_last_in_block.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Debug as last expression in block should return {}
|
||||
type=snippet
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
main = || {
|
||||
dbg "hello"
|
||||
}
|
||||
~~~
|
||||
# EXPECTED
|
||||
NIL
|
||||
# PROBLEMS
|
||||
NIL
|
||||
# TOKENS
|
||||
~~~zig
|
||||
LowerIdent,OpAssign,OpBar,OpBar,OpenCurly,
|
||||
KwDbg,StringStart,StringPart,StringEnd,
|
||||
CloseCurly,
|
||||
EndOfFile,
|
||||
~~~
|
||||
# PARSE
|
||||
~~~clojure
|
||||
(file
|
||||
(type-module)
|
||||
(statements
|
||||
(s-decl
|
||||
(p-ident (raw "main"))
|
||||
(e-lambda
|
||||
(args)
|
||||
(e-block
|
||||
(statements
|
||||
(s-dbg
|
||||
(e-string
|
||||
(e-string-part (raw "hello"))))))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
main = || {
|
||||
dbg "hello"
|
||||
}
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(d-let
|
||||
(p-assign (ident "main"))
|
||||
(e-lambda
|
||||
(args)
|
||||
(e-block
|
||||
(e-dbg
|
||||
(e-string
|
||||
(e-literal (string "hello"))))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt (type "({}) => {}")))
|
||||
(expressions
|
||||
(expr (type "({}) => {}"))))
|
||||
~~~
|
||||
Loading…
Add table
Add a link
Reference in a new issue