mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 04:02:41 +00:00
40 lines
451 B
Nim
40 lines
451 B
Nim
discard """
|
|
output: '''1
|
|
0
|
|
1
|
|
0
|
|
1
|
|
0
|
|
1
|
|
0'''
|
|
"""
|
|
|
|
import macros
|
|
|
|
macro test(a: typed, b: typed): expr =
|
|
newLit(a == b)
|
|
|
|
echo test(1, 1)
|
|
echo test(1, 2)
|
|
|
|
type
|
|
Obj = object of RootObj
|
|
Other = object of RootObj
|
|
|
|
echo test(Obj, Obj)
|
|
echo test(Obj, Other)
|
|
|
|
var a, b: int
|
|
|
|
echo test(a, a)
|
|
echo test(a, b)
|
|
|
|
macro test2: expr =
|
|
newLit(bindSym"Obj" == bindSym"Obj")
|
|
|
|
macro test3: expr =
|
|
newLit(bindSym"Obj" == bindSym"Other")
|
|
|
|
echo test2()
|
|
echo test3()
|