Add more snapshot tests

This commit is contained in:
Richard Feldman 2025-11-26 10:03:08 -05:00
parent 0129e34275
commit 55f04a0688
No known key found for this signature in database
2 changed files with 147 additions and 0 deletions

View 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"))))
~~~

View 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 "({}) => {}"))))
~~~